Idan Haviv - How I Stopped Hating Auto Layout

19
+ Auto layout by Idan Haviv Or: “Dude, where’s my view?!”

Transcript of Idan Haviv - How I Stopped Hating Auto Layout

Page 1: Idan Haviv - How I Stopped Hating Auto Layout

+

Auto layoutby Idan HavivOr: “Dude, where’s my view?!”

Page 2: Idan Haviv - How I Stopped Hating Auto Layout

+Motivation

Page 3: Idan Haviv - How I Stopped Hating Auto Layout

+Motivation

Page 4: Idan Haviv - How I Stopped Hating Auto Layout

+Auto Layout motivation

Design ONCE

Forward compatibility

Page 5: Idan Haviv - How I Stopped Hating Auto Layout

+Size Classes

Introduced in Xcode 6

Layer of Abstraction

Page 6: Idan Haviv - How I Stopped Hating Auto Layout

+Size Classes

Introduced in Xcode 6

Layer of Abstraction

Horizontal & Vertical Size Classes: Compact Or Regular

Page 7: Idan Haviv - How I Stopped Hating Auto Layout

+Size Classes

Page 8: Idan Haviv - How I Stopped Hating Auto Layout

+Size Classes

1. Interface Builder2. @property traitCollection: UITraitCollection

Page 9: Idan Haviv - How I Stopped Hating Auto Layout

+Size Classes

UITraitCollection:

display scale (retina/non-retina)size classesuser interface idiom (iphone ipad etc.)

Page 10: Idan Haviv - How I Stopped Hating Auto Layout

+Size Classes

UITraitCollection (and so, size classes) is inherited

Page 11: Idan Haviv - How I Stopped Hating Auto Layout

+Size ClassesWhat can be size class dependent?

Page 12: Idan Haviv - How I Stopped Hating Auto Layout

+Size ClassesWhat can be size class dependent?

Constraints installed/uninstalled;

Constraints constant

View’s position

View’s presence

Font properties

Page 13: Idan Haviv - How I Stopped Hating Auto Layout

+Constraints - Anatomy

Attribute1 = multiplier * Attribute2 + constant

Page 14: Idan Haviv - How I Stopped Hating Auto Layout

+Constraints - Anatomy

Attribute1 = multiplier * Attribute2 + constant

Page 15: Idan Haviv - How I Stopped Hating Auto Layout

+Hands On

Page 16: Idan Haviv - How I Stopped Hating Auto Layout

+Topics to further review

■ Visual Format Language

■ XCode 8 features:auto resizing mask + constraints on single screen

■ UIStackView (iOS 9)■ translatesAutoResizingMaskIntoConstraints ■ placeholder constraints & intrinsic content size

Page 18: Idan Haviv - How I Stopped Hating Auto Layout

+Questions?

Page 19: Idan Haviv - How I Stopped Hating Auto Layout

+Questions?

[email protected]