0

I'm looking for an example xCode project that can demonstrate how to apply autolayouts to UIViews programmatically. I see quite a lot of questions that deal with how to apply autolayout, but I'm a total novice and need something to play with before I can get a feeling for how autolayouts work.

Thank you!

Alex Stone
  • 46,408
  • 55
  • 231
  • 407
  • I don't know of any example projects, but I would suggest watching the 3 videos on the subject from WWDC 2012 ("Introduction to Auto Layout for iOS and OS X", "Best Practices for Mastering Auto Layout", and "Auto Layout by Example". They discuss both IB and code approaches in these videos. – rdelmar Apr 06 '13 at 15:52

1 Answers1

2

Take a look at this: http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2 (with IB) and this: http://www.techotopia.com/index.php/Implementing_iOS_6_Auto_Layout_Constraints_in_Code (without IB)

In addition: If you want to do it programmatically I would prefer to use math instead of complex AutoLayout statements. If you want to have a button placed 20pixel up from bottom just work with something like [[[[UIScreen mainscreen]bounds]size]height]-20] I think this is easier to work with.

arnoapp
  • 2,416
  • 4
  • 38
  • 70