class MotionKit::Layout
Public Instance Methods
add_child(subview, options={})
click to toggle source
# File lib/motion-kit-ios/helpers/uiview_helpers.rb, line 14 def add_child(subview, options={}) if (sibling = options[:behind]) target.insertSubview(subview, belowSubview: sibling) elsif (sibling = options[:in_front_of]) target.insertSubview(subview, aboveSubview: sibling) elsif (z_index = options[:z_index]) target.insertSubview(subview, atIndex: z_index) else target.addSubview(subview) end end
constraints(add_to_view=nil, &block)
click to toggle source
Ensure we always have a context in this method; makes it easier to define constraints in an `add_constraints` method.
# File lib/motion-kit-ios/helpers/uiview_constraints_helpers.rb, line 25 def constraints(add_to_view=nil, &block) if has_context? apply(:constraints, add_to_view, &block) else context(self.view) do constraints(add_to_view, &block) end end end
default_root()
click to toggle source
platform specific default root view
# File lib/motion-kit-ios/helpers/uiview_helpers.rb, line 8 def default_root # child Layout classes will return *their* UIView subclass from self.targets view_class = self.class.targets || MotionKit.default_view_class view_class.alloc.initWithFrame(UIScreen.mainScreen.applicationFrame) end
remove_child(subview)
click to toggle source
# File lib/motion-kit-ios/helpers/uiview_helpers.rb, line 26 def remove_child(subview) subview.removeFromSuperview end