4
rizza
8y

For iOS and OSX devs. Do you really know how auto layout works? It is something I do but don't know how it works

Comments
  • 0
    I don't have a ton of experience building native iOS apps but from the limited amount I've done auto-layout was always a little hard to wrap my head around. It seems pretty powerful though!
  • 0
    It is power full. I'm not display agreeing that. But no good explanations for universal apps
  • 6
    I've been using autolayout for a while now and they're pretty cool. A few quick tips if I may:

    1- it's always easier to set them up in Interface Builder than programmatically, because you can see how things will look like right away
    2- a constraint with any priority below 1000 can be changed programmatically
    3- change priorities instead of adding/activating/removing/deactivating constraints
    4- classes can have IBOutlets to constraints
  • 5
    5- changes to constraints are animatable by wrapping a view.layoutIfNeeded() call in an animation closure
    6- Regular constraints will affect iPads and iPhones 6 Pluses only and if present, otherwise fallback to Any Height or Width
    7- iPads do not respond to Compact constraints unless the device is in multi-app mode
    8- All other size classes are pertinent to iPhones only
    9- when 2 constraints compete for the same layout parameter (width, height, x and y), the highest priority one will prevail
  • 3
    Hope this helps!
  • 1
    Thanks for the tips!
Add Comment