Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Auto Layout in iOS
Search
Sam Kirchmeier
September 12, 2013
Programming
3
130
Auto Layout in iOS
Introduction to Auto Layout in iOS
Sam Kirchmeier
September 12, 2013
Tweet
Share
More Decks by Sam Kirchmeier
See All by Sam Kirchmeier
Exploring Stateless UIs in Swift
skirchmeier
2
520
Beyond REST: Web Services Designed for Mobile
skirchmeier
2
120
Physics-Based Interfaces with UIKit Dynamics
skirchmeier
0
100
Bluetooth LE, Core Bluetooth, and a Glimpse Into Your Near Future
skirchmeier
0
250
Building HTML5 Tablet Apps
skirchmeier
2
500
iOS Training Part 2
skirchmeier
1
200
Custom iOS Controls
skirchmeier
3
180
Other Decks in Programming
See All in Programming
Progressive Web Apps für Desktop und Mobile mit Angular (Hands-on)
christianliebel
PRO
0
110
From Subtype Polymorphism To Typeclass-based Ad hoc Polymorphism- An Example
philipschwarz
PRO
0
170
Dev ContainersとGitHub Codespacesの素敵な関係
ymd65536
1
130
GCCのプラグインを作る / I Made a GCC Plugin
shouth
1
150
役立つログに取り組もう
irof
27
8.7k
offers_20241022_imakiire.pdf
imakurusu
2
360
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
390
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
440
Macとオーディオ再生 2024/11/02
yusukeito
0
210
カラム追加で増えるActiveRecordのメモリサイズ イメージできますか?
asayamakk
4
1.6k
Hotwire or React? ~Reactの録画機能をHotwireに置き換えて得られた知見~ / hotwire_or_react
harunatsujita
9
4.1k
Vue SFCのtemplateでTypeScriptの型を活用しよう
tsukkee
3
1.5k
Featured
See All Featured
Code Review Best Practice
trishagee
64
17k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Building Your Own Lightsaber
phodgson
102
6.1k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.6k
GitHub's CSS Performance
jonrohan
1030
460k
YesSQL, Process and Tooling at Scale
rocio
167
14k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
504
140k
Visualization
eitanlees
144
15k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
7
150
Transcript
Auto Layout Sam Kirchmeier @skirchmeier Adam May @yammada Friday, September
27, 13
Friday, September 27, 13
Lineup Auto Layout crash course Ways to use it Demos
& discussion Friday, September 27, 13
Auto Layout Friday, September 27, 13
Friday, September 27, 13
Alternative to Springs & Struts Friday, September 27, 13
Alternative to Springs & Struts Relationships instead of frames Friday,
September 27, 13
Alternative to Springs & Struts Relationships instead of frames Layout
is resolved automatically Friday, September 27, 13
Alternative to Springs & Struts Relationships instead of frames Layout
is resolved automatically Magic Friday, September 27, 13
Who’s used it? Friday, September 27, 13
Why? Friday, September 27, 13
Friday, September 27, 13
Easy Friday, September 27, 13
Easy Versatile Friday, September 27, 13
Easy Versatile Descriptive Friday, September 27, 13
Easy Versatile Descriptive Localizable Friday, September 27, 13
Springs & Struts Auto Layout Friday, September 27, 13
Springs & Struts Auto Layout Hard-coded Friday, September 27, 13
Springs & Struts Auto Layout Hard-coded Content-driven Friday, September 27,
13
Springs & Struts Auto Layout Hard-coded Isolated Views Content-driven Friday,
September 27, 13
Springs & Struts Auto Layout Hard-coded Isolated Views Content-driven Related
Views Friday, September 27, 13
Springs & Struts Auto Layout Hard-coded Isolated Views autoResizingMask Content-driven
Related Views Friday, September 27, 13
Springs & Struts Auto Layout Hard-coded Isolated Views autoResizingMask Content-driven
Related Views Constraints Friday, September 27, 13
Springs & Struts Auto Layout Hard-coded Isolated Views autoResizingMask Familiar
Content-driven Related Views Constraints Friday, September 27, 13
Springs & Struts Auto Layout Hard-coded Isolated Views autoResizingMask Familiar
Content-driven Related Views Constraints Scary Friday, September 27, 13
Constraints Friday, September 27, 13
Scary Friday, September 27, 13
Scary Friday, September 27, 13
Scary Friday, September 27, 13
Scary attribute attribute == x multiplier + constant Friday, September
27, 13
Scary attribute attribute == x multiplier + constant Friday, September
27, 13
Scary attribute == x multiplier + constant top Friday, September
27, 13
Scary attribute == x multiplier + constant top Friday, September
27, 13
Scary attribute == x multiplier + constant top Friday, September
27, 13
Scary == x multiplier + constant top top Friday, September
27, 13
Scary == x multiplier + constant top top Friday, September
27, 13
Scary == x + constant top top 1.0 Friday, September
27, 13
Scary == + constant top top Friday, September 27, 13
Scary == + top top standard Friday, September 27, 13
Scary == + top top standard Friday, September 27, 13
Scary == + top top standard le! le! == +
standard Friday, September 27, 13
Scary == + top top standard le! le! == +
standard Same behavior as Springs & Struts No frame necessary Friday, September 27, 13
Le! Top Baseline Width Center X Right Bottom None Height
Center Y Friday, September 27, 13
Le! Top Baseline Width Center X Right Bottom None Height
Center Y Leading Trailing Friday, September 27, 13
Scary Friday, September 27, 13
!"#$ Friday, September 27, 13
Unsatisfiability Friday, September 27, 13
Ambiguity Friday, September 27, 13
Content Hugging Compression Resistance Intrinsic Content Size Friday, September 27,
13
Priorities Friday, September 27, 13
Ways to use it Interface Builder NSLayoutConstraint Visual Format Language
Friday, September 27, 13
Interface Builder Friday, September 27, 13
NSLayoutConstraint Friday, September 27, 13
NSLayoutConstraint + (id)constraintWithItem:(id)view1 attribute:(NSLayoutAttribute)attr1 relatedBy:(NSLayoutRelation)relation toItem:(id)view2 attribute:(NSLayoutAttribute)attr2 multiplier:(CGFloat)multiplier constant:(CGFloat)constant; Friday,
September 27, 13
[NSLayoutConstraint constraintWithItem:view1 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:view2 attribute:NSLayoutAttributeTop multiplier:1.0 constant:20.0]; == x
1.0 + 20.0 top top Friday, September 27, 13
[NSLayoutConstraint constraintWithItem:view1 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:view2 attribute:NSLayoutAttributeTop multiplier:1.0 constant:20.0]; == x
1.0 + 20.0 top top Friday, September 27, 13
[NSLayoutConstraint constraintWithItem:view1 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:view2 attribute:NSLayoutAttributeTop multiplier:1.0 constant:20.0]; == x
1.0 + 20.0 top top Friday, September 27, 13
[NSLayoutConstraint constraintWithItem:view1 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:view2 attribute:NSLayoutAttributeTop multiplier:1.0 constant:20.0]; == x
1.0 + 20.0 top top Friday, September 27, 13
[NSLayoutConstraint constraintWithItem:view1 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:view2 attribute:NSLayoutAttributeTop multiplier:1.0 constant:20.0]; == x
1.0 + 20.0 top top Friday, September 27, 13
[NSLayoutConstraint constraintWithItem:view1 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:view2 attribute:NSLayoutAttributeTop multiplier:1.0 constant:20.0]; == x
1.0 + 20.0 top top Friday, September 27, 13
Visual Format Language Friday, September 27, 13
[label]-[textField] Friday, September 27, 13
|-[label]-| Friday, September 27, 13
V:|-(40)-[logo] Friday, September 27, 13
|-(40)-[logo]-[label]-[textField(>=20)]-| Friday, September 27, 13
[NSLayoutConstraint constraintsWithVisualFormat:@"|-[label]" options:0 metrics:nil views:views]; [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[label]" options:0 metrics:nil views:views];
Friday, September 27, 13
Demo Localization Friday, September 27, 13
Demo Free Form Editor Friday, September 27, 13
UITextView UIScrollView UIMapView Friday, September 27, 13
UITextView UIScrollView UIMapView Friday, September 27, 13
UIImageView UIView Friday, September 27, 13
Z UIScrollView UIImageView UIScrollView contentSize Friday, September 27, 13
Demo Free Form Editor Friday, September 27, 13
Constraint Stacking Friday, September 27, 13
UITextView UIScrollView UIMapView Image Views Friday, September 27, 13
UIImageView UIImageView UIImageView Friday, September 27, 13
UIImageView UIImageView ? ? Friday, September 27, 13
UIImageView UIImageView UIImageView Friday, September 27, 13
UIImageView UIImageView UIImageView ≥20 ≥20 ≥20 Friday, September 27, 13
UIImageView UIImageView ≥20 ≥20 Friday, September 27, 13
Demo Constraint Stacking Friday, September 27, 13
Interface Builder Quirks Friday, September 27, 13
Friday, September 27, 13
Easy to accidentally delete outlets Friday, September 27, 13
Easy to accidentally delete outlets Does not allow ambiguity Friday,
September 27, 13
Easy to accidentally delete outlets Does not allow ambiguity Adds
minimum best constraints Friday, September 27, 13
Easy to accidentally delete outlets Does not allow ambiguity Adds
minimum best constraints Automatically promotes constraints Friday, September 27, 13
Easy to accidentally delete outlets Does not allow ambiguity Adds
minimum best constraints Automatically promotes constraints Automatically deletes constraints Friday, September 27, 13
Interface Builder Tips Friday, September 27, 13
Friday, September 27, 13
Friday, September 27, 13
Change to portrait/landscape/freeform Friday, September 27, 13
Change to portrait/landscape/freeform Promote constraints to User Constraints Friday, September
27, 13
Change to portrait/landscape/freeform Promote constraints to User Constraints Learn to
expect what IB will do Friday, September 27, 13
Change to portrait/landscape/freeform Promote constraints to User Constraints Learn to
expect what IB will do Size to fit content Friday, September 27, 13
Change to portrait/landscape/freeform Promote constraints to User Constraints Learn to
expect what IB will do Size to fit content Wait for Xcode 5 Friday, September 27, 13
Recap Introduced Auto Layout Ways to use it Demos Friday,
September 27, 13
Discussion https://github.com/livefront/autolayout Sam Kirchmeier @skirchmeier Adam May @yammada Friday, September
27, 13