class UIView

Public Instance Methods

add_border(locations, color, width = 1)
Alias for: add_borders
add_border_with_frame(color, frame) click to toggle source
# File lib/project/ui_view.rb, line 39
def add_border_with_frame(color, frame)
  color = color.CGColor if color.is_a?(UIColor)
  border = CALayer.layer.tap do |l|
    l.backgroundColor = color
    l.frame = frame
  end
  self.layer.addSublayer(border)
end
add_borders(locations, color, width = 1) click to toggle source
# File lib/project/ui_view.rb, line 2
def add_borders(locations, color, width = 1)
  possible_locations = [:top, :left, :right, :bottom]
  Array(locations).each do |location|
    if possible_locations.include?(location)
      method_call = "add_#{location.to_s}_border"
      self.send(method_call, color, width)
    else
      puts "You must provide a border location in: #{possible_locations}"
    end
  end
  self
end
Also aliased as: add_border
add_bottom_border(color, width) click to toggle source
# File lib/project/ui_view.rb, line 31
def add_bottom_border(color, width)
  add_border_with_frame(color, CGRectMake(0, CGRectGetHeight(self.frame) - width, CGRectGetWidth(self.frame), width))
end
add_left_border(color, width) click to toggle source
# File lib/project/ui_view.rb, line 35
def add_left_border(color, width)
  add_border_with_frame(color, CGRectMake(0, 0, width, CGRectGetHeight(self.frame)))
end
add_right_border(color, width) click to toggle source
# File lib/project/ui_view.rb, line 27
def add_right_border(color, width)
  add_border_with_frame(color, CGRectMake(CGRectGetWidth(self.frame) - width, 0, width, CGRectGetHeight(self.frame)))
end
add_top_border(color, width) click to toggle source
# File lib/project/ui_view.rb, line 23
def add_top_border(color, width)
  add_border_with_frame(color, CGRectMake(0, 0, CGRectGetWidth(self.frame), width))
end
remove_border()
Alias for: remove_borders
remove_borders() click to toggle source
# File lib/project/ui_view.rb, line 16
def remove_borders
  self.layer.sublayers.copy.each do |layer|
    layer.removeFromSuperlayer
  end if self.layer.sublayers
end
Also aliased as: remove_border