Sha256: 8dabda5afc2fdf0d1c6c480b7a6396e2323c12ed947760a5c31325bec83f6fc2

Contents?: true

Size: 851 Bytes

Versions: 2

Compression:

Stored size: 851 Bytes

Contents

# @requires MotionKit::UIViewLayout
module MotionKit
  class UIViewLayout

    def constraints(view=nil, &block)
      view ||= target
      if view.is_a?(Symbol)
        view = self.get(view)
      end
      view.setTranslatesAutoresizingMaskIntoConstraints(false)

      constraints_target = ConstraintsTarget.new(view)
      deferred(constraints_target) do
        context(constraints_target, &block)
        constraints_target.apply_all_constraints(self, view)
      end
    end

  end

  class Layout

    # Ensure we always have a context in this method; makes it easier to define
    # constraints in an `add_constraints` method.
    def constraints(view=nil, &block)
      if target
        apply(:constraints, view, &block)
      else
        context(self.view) do
          constraints(view, &block)
        end
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
motion-kit-0.10.10 lib/motion-kit-ios/layouts/uiview_layout_constraints.rb
motion-kit-0.10.9 lib/motion-kit-ios/layouts/uiview_layout_constraints.rb