Class: MotionPrime::LabelElement
- Inherits:
-
BaseElement
- Object
- BaseElement
- MotionPrime::LabelElement
- Defined in:
- motion-prime/elements/label.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from BaseElement
#name, #options, #screen, #section, #styles, #view, #view_name
Instance Method Summary collapse
- #set_text(value) ⇒ Object
- #size_to_fit ⇒ Object
- #size_to_fit_if_needed ⇒ Object
- #view_class ⇒ Object
Methods included from ElementTextMixin
#attributed_string, #extract_attributed_string_options, #html_string
Methods included from ElementContentTextMixin
#attributed_text?, #attributed_text_for_text, #cached_content_height, #cached_content_width, #content_font, #content_height, #content_text, #content_width, #current_attributed_text, #height_for_attributed_text, #height_for_text, #width_for_attributed_text, #width_for_text
Methods included from ElementContentPaddingMixin
#cached_content_outer_height, #cached_content_outer_width, #content_outer_height, #content_outer_width, #content_padding_bottom, #content_padding_height, #content_padding_left, #content_padding_right, #content_padding_top, #content_padding_width, #default_padding_for
Methods inherited from BaseElement
#add_target, after_render, before_render, #bind_gesture, #cell_element?, #cell_section?, #compute_options!, #computed_options, #dealloc, factory, #hide, #initialize, #reload!, #render, #render!, #rerender!, #show, #update, #update_options, #update_with_options
Methods included from HasClassFactory
#camelize_factory, #class_factory, #low_camelize_factory
Methods included from HasStyleChainBuilder
Methods included from HasNormalizer
#debug_info, #element?, #normalize_object, #normalize_options, #normalize_value
Constructor Details
This class inherits a constructor from MotionPrime::BaseElement
Instance Method Details
#set_text(value) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'motion-prime/elements/label.rb', line 33 def set_text(value) [:text] = value styler = ViewStyler.new(view, CGRectZero, ) if styler.[:attributed_text] view.attributedText = styler.[:attributed_text] else view.text = value end @content_height = nil size_to_fit end |
#size_to_fit ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'motion-prime/elements/label.rb', line 14 def size_to_fit if [:size_to_fit] if [:width] view.setHeight([cached_content_outer_height, [:height]].compact.min) else view.sizeToFit # we should re-set values, because sizeToFit do not use padding view.setWidth(view.bounds.size.width + content_padding_width) view.setHeight(view.bounds.size.height + content_padding_height) end end end |
#size_to_fit_if_needed ⇒ Object
27 28 29 30 31 |
# File 'motion-prime/elements/label.rb', line 27 def size_to_fit_if_needed if [:size_to_fit] && [:width] @computed_options[:height_to_fit] = content_outer_height end end |
#view_class ⇒ Object
10 11 12 |
# File 'motion-prime/elements/label.rb', line 10 def view_class "MPLabel" end |