module UnderOs::UI::Style::Outlining
Public Instance Methods
backgroundColor()
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 15 def backgroundColor @view.backgroundColor end
Also aliased as: background
backgroundColor=(color, state=UIControlStateNormal)
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 19 def backgroundColor=(color, state=UIControlStateNormal) if @view.is_a?(UIButton) @view.setBackgroundColor convert_color(color), forState:state else @view.backgroundColor = convert_color(color) end end
Also aliased as: background=
backgroundImage()
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 27 def backgroundImage @background_image end
backgroundImage=(image)
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 31 def backgroundImage=(image) image = UIImage.UIImage.imageNamed(image) if image.is_a?(String) if @view.is_a?(UIButton) @view.setBackgroundImage(image, forState:UIControlStateNormal) else @background_image = UnderOs::UI::Image.new(src: image, class: 'uos-background-image') @background_image._.frame = [[0, 0], [@view.frame.size.width, @view.frame.size.height]] @view.insertSubview(@background_image._, atIndex: 0) end end
borderColor()
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 75 def borderColor @view.layer.borderColor end
borderColor=(color)
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 79 def borderColor=(color) @view.layer.borderColor = convert_color(color).CGColor end
borderRadius()
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 66 def borderRadius @view.layer.cornerRadius end
borderRadius=(radius)
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 70 def borderRadius=(radius) @view.clipsToBounds = true @view.layer.cornerRadius = radius end
borderWidth()
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 83 def borderWidth @view.layer.borderWidth end
borderWidth=(width)
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 87 def borderWidth=(width) @view.layer.borderWidth = width end
boxShadow()
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 91 def boxShadow get_layer_shadow @view.layer end
boxShadow=(value)
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 95 def boxShadow=(value) set_layer_shadow @view.layer, value end
color(state=UIControlStateNormal)
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 46 def color(state=UIControlStateNormal) if @view.is_a?(UIButton) @view.titleColorForState(state) elsif @view.respond_to?(:textColor) @view.textColor elsif @view.respond_to?(:color) @view.color end end
color=(color, state=UIControlStateNormal)
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 56 def color=(color, state=UIControlStateNormal) if @view.is_a?(UIButton) @view.setTitleColor convert_color(color), forState:state elsif @view.respond_to?(:textColor) @view.textColor = convert_color(color) elsif @view.respond_to?(:color) @view.color = convert_color(color) end end
opacity()
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 7 def opacity @view.alpha end
opacity=(value)
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 11 def opacity=(value) @view.alpha = value end
textShadow()
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 99 def textShadow get_layer_shadow text_layer end
textShadow=(value)
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 103 def textShadow=(value) set_layer_shadow text_layer, value end
Private Instance Methods
convert_color(color)
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 109 def convert_color(color) UnderOs::Color.new(color).ui end
get_layer_shadow(layer)
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 117 def get_layer_shadow(layer) [ layer.shadowOffset.width, layer.shadowOffset.height, layer.shadowRadius, layer.shadowOpacity, UnderOs::Color.new(layer.shadowColor).to_hex ].compact.join(" ") end
parse_shadow_params(string)
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 137 def parse_shadow_params(string) x, y, radius, opacity, color = string.strip.split x = x.gsub /px$/, '' y = y.gsub /px$/, '' radius = radius.gsub /px$/, '' if radius opacity = opacity.gsub /px$/, '' if opacity if ! color if opacity unless opacity =~ /^[\d\.]+$/ color = opacity opacity = nil end elsif radius unless radius =~ /^[\d\.]+$/ color = radius radius = nil end end end x = x.to_f if x y = y.to_f if y radius = radius.to_f if radius opacity = opacity.to_f if opacity color = convert_color(color) if color [x, y, radius, opacity, color] end
set_layer_shadow(layer, value)
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 127 def set_layer_shadow(layer, value) x, y, radius, opacity, color = parse_shadow_params(value) layer.shadowOffset = CGSizeMake(x, y) if x && y layer.shadowColor = color.CGColor if color layer.shadowRadius = radius if radius layer.shadowOpacity = opacity if opacity layer.shadowPath = UIBezierPath.bezierPathWithRect(@view.layer.bounds).CGPath end
text_layer()
click to toggle source
# File lib/under_os/ui/style/outlining.rb, line 113 def text_layer @view.is_a?(UIButton) ? @view.titleLabel : @view.layer end