colinta / teacup

This project has been sunset in favor of MotionKit
github.com/motion-kit/motion-kit
Other
602 stars 85 forks source link

Add identifier to constraints #155

Closed ahmeij closed 10 years ago

ahmeij commented 10 years ago

Add identifier as a configurable option.

constraint_height(40).identifier("my_height")

use like this (console example)

a(25).get_ns_constraints.select{|c| c.identifier == "height"}.first

Weird unrelated fact, the a(25).constraints is always [](blank array) and does not contain the constraints.

This way constraints can be programmatically looked up. Unfortunately changing them dynamically does not work because the get_ns_constrains does not list the constraints by reference :(

colinta commented 10 years ago

Certainly being able to change/access identifier is handy, but as you point out, constraints aren't easily found in the get_ns_constraints method... but you should be able to get to them from the UIView#constraints method directly! You should be able to animated them that way, too, I think...

c = a(25).constraints.find { |constraint| contsraint.identifier == 'my_id' }