motion-prime/views/view_styler.rb in motion-prime-1.0.2 vs motion-prime/views/view_styler.rb in motion-prime-1.0.3
- old
+ new
@@ -3,11 +3,15 @@
include FrameCalculatorMixin
include HasStyles
include HasClassFactory
include ElementTextMixin
- ORDER = %w[frame font placeholder_font text title_label title]
+ ORDER = %w[
+ frame
+ font placeholder_font text title_label title
+ minimum_value maximum_value value
+ ]
attr_reader :view, :options
def initialize(view, parent_bounds = CGRectZero, options = {})
@options = Styles.extend_and_normalize_options(options)
@@ -61,18 +65,18 @@
# ios 7 bug fix when text is invisible
if text_options.slice(:line_height, :line_spacing, :text_alignment, :line_break_mode).any? && options.fetch(:number_of_lines, 1) == 1
options[:number_of_lines] = 0
end
end
+ # Fix issue overriding background color
+ if options[:background_image].present?
+ options.delete(:background_color)
+ end
extract_font_options(options)
extract_font_options(options, 'placeholder')
- @options = Hash[
- options.sort_by do |k,v|
- index = ORDER.index(k.to_s) || -1
- end.reverse
- ]
+ @options = Hash[options.sort_by {|k,v| ORDER.index(k.to_s) || ORDER.count }]
end
def extract_font_options(options, prefix = nil)
key = [prefix, 'font'].compact.join('_').to_sym
name_key = [prefix, 'font_name'].compact.join('_').to_sym
@@ -225,9 +229,11 @@
stroke_layer = CAShapeLayer.layer
stroke_layer.path = mask_path.CGPath
stroke_layer.fillColor = :clear.uicolor.cgcolor
stroke_layer.strokeColor = value[:border_color].uicolor.cgcolor
stroke_layer.lineWidth = value[:border_width].to_f*2 # another half is hidden by the mask
+
+ stroke_layer.lineDashPattern = value[:dashes] if value[:dashes].present?
container_view = view.delegate
stroke_view = UIView.alloc.initWithFrame(layer_bounds)
stroke_view.userInteractionEnabled = false
stroke_view.layer.addSublayer(stroke_layer)