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
Shuai Liu
September 22, 2015
Technology
2
120
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
68
Python-intro-1
liushuaikobe
0
65
GitRadar——毕业论文答辩
liushuaikobe
0
180
NoSQL & MongoDB
liushuaikobe
0
150
Other Decks in Technology
See All in Technology
今から間に合う re:Invent 準備グッズと現地の地図、その他ラスベガスを周る際の Tips/reinvent-preparation-guide
emiki
0
120
GTC 2025 : 가속되고 있는 미래
inureyes
PRO
0
140
AIでデータ活用を加速させる取り組み / Leveraging AI to accelerate data utilization
okiyuki99
6
1.5k
GPUをつかってベクトル検索を扱う手法のお話し~NVIDIA cuVSとCAGRA~
fshuhe
0
290
激動の時代を爆速リチーミングで乗り越えろ
sansantech
PRO
1
190
Raycast AI APIを使ってちょっと便利なAI拡張機能を作ってみた
kawamataryo
0
220
어떤 개발자가 되고 싶은가?
arawn
1
290
OTEPsで知るOpenTelemetryの未来 / Observability Conference Tokyo 2025
arthur1
0
350
abema-trace-sampling-observability-cost-optimization
tetsuya28
0
380
アノテーション作業書作成のGood Practice
cierpa0905
PRO
1
330
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
2
170
【SORACOM UG Explorer 2025】さらなる10年へ ~ SORACOM MVC 発表
soracom
PRO
0
180
Featured
See All Featured
A designer walks into a library…
pauljervisheath
209
24k
jQuery: Nuts, Bolts and Bling
dougneiner
65
7.9k
The Cult of Friendly URLs
andyhume
79
6.6k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.2k
Intergalactic Javascript Robots from Outer Space
tanoku
272
27k
Stop Working from a Prison Cell
hatefulcrawdad
272
21k
Building a Scalable Design System with Sketch
lauravandoore
463
33k
How GitHub (no longer) Works
holman
315
140k
We Have a Design System, Now What?
morganepeng
53
7.9k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
640
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
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