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
140
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
560
Beyond REST: Web Services Designed for Mobile
skirchmeier
2
120
Physics-Based Interfaces with UIKit Dynamics
skirchmeier
0
110
Bluetooth LE, Core Bluetooth, and a Glimpse Into Your Near Future
skirchmeier
0
260
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
『改訂新版 良いコード/悪いコードで学ぶ設計入門』活用方法−爆速でスキルアップする!効果的な学習アプローチ / effective-learning-of-good-code
minodriven
28
4.2k
AHC041解説
terryu16
0
400
AppRouterを用いた大規模サービス開発におけるディレクトリ構成の変遷と問題点
eiganken
1
450
PicoRubyと暮らす、シェアハウスハック
ryosk7
0
230
毎日13時間もかかるバッチ処理をたった3日で60%短縮するためにやったこと
sho_ssk_
1
550
ErdMap: Thinking about a map for Rails applications
makicamel
1
680
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
1.4k
盆栽転じて家具となる / Bonsai and Furnitures
aereal
0
1.9k
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
770
chibiccをCILに移植した結果 (NGK2025S版)
kekyo
PRO
0
140
AWSのLambdaで PHPを動かす選択肢
rinchoku
2
390
はてなにおけるfujiwara-wareの活用やecspressoのCI/CD構成 / Fujiwara Tech Conference 2025
cohalz
3
2.8k
Featured
See All Featured
Java REST API Framework Comparison - PWX 2021
mraible
28
8.3k
Optimizing for Happiness
mojombo
376
70k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
We Have a Design System, Now What?
morganepeng
51
7.3k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.4k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.6k
Navigating Team Friction
lara
183
15k
How to train your dragon (web standard)
notwaldorf
89
5.8k
Making Projects Easy
brettharned
116
6k
Agile that works and the tools we love
rasmusluckow
328
21k
How to Ace a Technical Interview
jacobian
276
23k
Side Projects
sachag
452
42k
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