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.pdf
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Shuai Liu
September 22, 2015
Technology
2
130
Auto-Layout.pdf
Shuai Liu
September 22, 2015
Tweet
Share
More Decks by Shuai Liu
See All by Shuai Liu
Python-intro-2
liushuaikobe
0
79
Python-intro-1
liushuaikobe
0
74
GitRadar——毕业论文答辩
liushuaikobe
0
180
NoSQL & MongoDB
liushuaikobe
0
180
Other Decks in Technology
See All in Technology
スピンアウト講座05_実践活用事例
overflowinc
0
770
Kiroで見直す開発プロセスとAI-DLC
k_adachi_01
0
110
2026年もソフトウェアサプライチェーンのリスクに立ち向かうために / Product Security Square #3
flatt_security
1
740
生成AI活用でQAエンジニアにどのような仕事が生まれるか/Support Required of QA Engineers for Generative AI
goyoki
1
360
Phase01_AI座学_基礎
overflowinc
0
2.7k
DDD×仕様駆動で回す高品質開発のプロセス設計
littlehands
4
2k
AlloyDB 奮闘記
hatappi
0
190
ABEMAのバグバウンティの取り組み
kurochan
1
390
ReactのdangerouslySetInnerHTMLは“dangerously”だから危険 / Security.any #09 卒業したいセキュリティLT
flatt_security
0
450
GCASアップデート(202601-202603)
techniczna
0
250
スピンアウト講座01_GitHub管理
overflowinc
0
900
SSoT(Single Source of Truth)で「壊して再生」する設計
kawauso
1
230
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
37
3.6k
The SEO Collaboration Effect
kristinabergwall1
0
400
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.5k
Heart Work Chapter 1 - Part 1
lfama
PRO
5
35k
Designing for humans not robots
tammielis
254
26k
How STYLIGHT went responsive
nonsquared
100
6k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.2k
For a Future-Friendly Web
brad_frost
183
10k
The Spectacular Lies of Maps
axbom
PRO
1
640
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
230
Thoughts on Productivity
jonyablonski
75
5.1k
Unsuck your backbone
ammeep
672
58k
Transcript
Auto Layout
Frame + autoresizingMask Auto Layout
basis • SuperView的位置确定了,那么SubView的位置就可 以被确定 • SuperView -> SubView的{x, y, width,
height} -> SubView的位置
Cassowary You provide rules, whether through IB or through code,
and the Auto Layout system transforms those rules into view frames.
Constraint y = kx + b view1的某个属性 = k ×
view2的某个属性 + b
NSLayoutConstraint + (instancetype)constraintWithItem:(id)view1 attribute:(NSLayoutAtribute)attr1 relatedBy:(NSLayoutRelation)relation toItem:(id)view2 attribute:(NSLayoutAttribute)attr2 multiplier:(CGFloat)multipler constant:(CGFloat)c
开始Auto Layout • No frame & autoresizingMask • ⽗父View当前的⼤大⼩小是不可靠的
None
思路 • 合理的把⼦子View分组 • 确定⼤大致依赖关系 —— 要想确定A的位置,⾸首先我得知道B 的位置 & 只要B的位置定下来了,那么A的位置就可以被确定
• 找出那些只依赖⽗父View的View(⼀一定存在),先 添加他们的约束 • 根据依赖关系,⼀一级⼀一级的添加约束
None
None
None
Code
Advanced • Content Hugging & Compression Resistance • Intrinsic Content
Size • Animation