motion-prime/elements/label.rb in motion-prime-0.7.0 vs motion-prime/elements/label.rb in motion-prime-0.7.1
- old
+ new
@@ -1,9 +1,10 @@
module MotionPrime
class LabelElement < BaseElement
- include MotionPrime::ElementContentPaddingMixin
- include MotionPrime::ElementContentTextMixin
+ include ElementContentPaddingMixin
+ include ElementContentTextMixin
+ include ElementTextMixin
before_render :size_to_fit_if_needed
after_render :size_to_fit
def view_class
@@ -25,8 +26,20 @@
def size_to_fit_if_needed
if computed_options[:size_to_fit] && computed_options[:width]
@computed_options[:height_to_fit] = cached_content_outer_height
end
+ end
+
+ def set_text(value)
+ computed_options[:text] = value
+ styler = ViewStyler.new(view, CGRectZero, computed_options)
+ if styler.options[:attributed_text]
+ view.attributedText = styler.options[:attributed_text]
+ else
+ view.text = value
+ end
+ @content_height = nil
+ size_to_fit
end
end
end
\ No newline at end of file