Sha256: 9b0e11096193cad66a203faac30bded971590aeef3990b0cf2876a9e77c6993f

Contents?: true

Size: 835 Bytes

Versions: 14

Compression:

Stored size: 835 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)

      deferred do
        constraints_target = ConstraintsTarget.new(view)
        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 @context
        apply(:constraints, view, &block)
      else
        context(self.view) do
          constraints(view, &block)
        end
      end
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
motion-kit-0.10.7 lib/motion-kit-ios/layouts/uiview_layout_constraints.rb
motion-kit-0.10.6 lib/motion-kit-ios/layouts/uiview_layout_constraints.rb
motion-kit-0.10.5 lib/motion-kit-ios/layouts/uiview_layout_constraints.rb
motion-kit-0.10.4 lib/motion-kit-ios/layouts/uiview_layout_constraints.rb
motion-kit-0.10.3 lib/motion-kit-ios/layouts/uiview_layout_constraints.rb
motion-kit-0.10.2 lib/motion-kit-ios/layouts/uiview_layout_constraints.rb
motion-kit-0.10.1 lib/motion-kit-ios/layouts/uiview_layout_constraints.rb
motion-kit-0.10.0 lib/motion-kit-ios/layouts/uiview_layout_constraints.rb
motion-kit-0.9.6 lib/motion-kit-ios/layouts/uiview_layout_constraints.rb
motion-kit-0.9.4 lib/motion-kit-ios/layouts/uiview_layout_constraints.rb
motion-kit-0.9.3 lib/motion-kit-ios/layouts/uiview_layout_constraints.rb
motion-kit-0.9.2 lib/motion-kit-ios/layouts/uiview_layout_constraints.rb
motion-kit-0.9.1 lib/motion-kit-ios/layouts/uiview_layout_constraints.rb
motion-kit-0.9.0 lib/motion-kit-ios/layouts/uiview_layout_constraints.rb