motion-prime/views/view_styler.rb in motion-prime-0.9.9 vs motion-prime/views/view_styler.rb in motion-prime-0.9.9.1
- old
+ new
@@ -3,10 +3,12 @@
include FrameCalculatorMixin
include HasStyles
include HasClassFactory
include ElementTextMixin
+ ORDER = %w[font placeholder_font text]
+
attr_reader :view, :options
def initialize(view, parent_bounds = CGRectZero, options = {})
@options = Styles.extend_and_normalize_options options
@view = view
@@ -44,11 +46,11 @@
end
def prepare_options!
if options[:size_to_fit]
options[:line_break_mode] ||= :word_wrap
- options[:number_of_lines] ||= 0
+ options[:number_of_lines] ||= 0 if view.is_a?(UILabel)
end
if options.slice(:html, :line_spacing, :line_height, :underline, :fragment_color).any?
text_options = extract_attributed_text_options(options)
@@ -61,9 +63,11 @@
options[:number_of_lines] = 0
end
end
extract_font_options(options)
extract_font_options(options, 'placeholder')
+
+ @options = Hash[options.sort_by { |k,v| ORDER.index(k.to_s).to_i }]
end
def extract_font_options(options, prefix = nil)
key = [prefix, 'font'].compact.join('_').to_sym
name_key = [prefix, 'font_name'].compact.join('_').to_sym