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