Sha256: 0fff5cf2de3a730f18944654f0ee311233b2767eac29c8eb696b3a409b7d2f54

Contents?: true

Size: 941 Bytes

Versions: 21

Compression:

Stored size: 941 Bytes

Contents

# @requires MotionKit::UIViewHelpers
module MotionKit
  class UIViewHelpers

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

      constraints_target = ConstraintsTarget.new(add_to_view)
      deferred(constraints_target) do
        context(constraints_target, &block)
        constraints_target.apply_all_constraints(self, add_to_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(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

  end
end

Version data entries

21 entries across 15 versions & 1 rubygems

Version Path
motion-kit-1.1.1 lib/motion-kit-tvos/helpers/uiview_constraints_helpers.rb
motion-kit-1.1.1 lib/motion-kit-ios/helpers/uiview_constraints_helpers.rb
motion-kit-1.1.0 lib/motion-kit-ios/helpers/uiview_constraints_helpers.rb
motion-kit-1.1.0 lib/motion-kit-tvos/helpers/uiview_constraints_helpers.rb
motion-kit-1.0.3 lib/motion-kit-tvos/helpers/uiview_constraints_helpers.rb
motion-kit-1.0.3 lib/motion-kit-ios/helpers/uiview_constraints_helpers.rb
motion-kit-1.0.2 lib/motion-kit-tvos/helpers/uiview_constraints_helpers.rb
motion-kit-1.0.2 lib/motion-kit-ios/helpers/uiview_constraints_helpers.rb
motion-kit-1.0.1 lib/motion-kit-ios/helpers/uiview_constraints_helpers.rb
motion-kit-1.0.1 lib/motion-kit-tvos/helpers/uiview_constraints_helpers.rb
motion-kit-1.0.0 lib/motion-kit-tvos/helpers/uiview_constraints_helpers.rb
motion-kit-1.0.0 lib/motion-kit-ios/helpers/uiview_constraints_helpers.rb
motion-kit-0.18.0 lib/motion-kit-ios/helpers/uiview_constraints_helpers.rb
motion-kit-0.17.0 lib/motion-kit-ios/helpers/uiview_constraints_helpers.rb
motion-kit-0.16.0 lib/motion-kit-ios/helpers/uiview_constraints_helpers.rb
motion-kit-0.15.0 lib/motion-kit-ios/helpers/uiview_constraints_helpers.rb
motion-kit-0.14.2 lib/motion-kit-ios/helpers/uiview_constraints_helpers.rb
motion-kit-0.14.1 lib/motion-kit-ios/helpers/uiview_constraints_helpers.rb
motion-kit-0.14.0 lib/motion-kit-ios/helpers/uiview_constraints_helpers.rb
motion-kit-0.13.0 lib/motion-kit-ios/helpers/uiview_constraints_helpers.rb