简体   繁体   中英

Is there a way to add constraints into the xcode storyboard with code?

I see that in the storyboard, under Constraints, it lists all of the constraints being used. I am currently doing video tutorials and I think it would be a lot easier to simply write down what I see instead of dragging and connecting everything right now. Is there a way to do this?

Yes. The respective classes to use are 'NSLayoutConstraint' and 'NSLayoutAnchor'. It is described in the programming guide "Auto Layout Guide".

BTW: I just found another question that actually shows some code how to use it: How to set UITextField width constraint to have room for a certain string

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM