Sha256: ee7a2e1753522550b0b95b318246457c759fa8113ffa43c83049b2620810afb0

Contents?: true

Size: 996 Bytes

Versions: 3

Compression:

Stored size: 996 Bytes

Contents

# @provides MotionKit::Layout
# @provides MotionKit::UIViewHelpers
# @requires MotionKit::TreeLayout
module MotionKit
  class Layout < TreeLayout

    # platform specific default root view
    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

    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

    def remove_child(subview)
      subview.removeFromSuperview
    end

  end

  class UIViewHelpers < Layout
    targets UIView
  end

end

Version data entries

3 entries across 2 versions & 1 rubygems

Version Path
motion-kit-1.1.1 lib/motion-kit-ios/helpers/uiview_helpers.rb
motion-kit-1.1.1 lib/motion-kit-tvos/helpers/uiview_helpers.rb
motion-kit-1.1.0 lib/motion-kit-ios/helpers/uiview_helpers.rb