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
110
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
62
Python-intro-1
liushuaikobe
0
58
GitRadar——毕业论文答辩
liushuaikobe
0
170
NoSQL & MongoDB
liushuaikobe
0
120
Other Decks in Technology
See All in Technology
とあるEdTechベンチャーのシステム構成こだわりN選 / edtech-system
gotok365
3
170
続・やっぱり余白が大切だった話
kakehashi
PRO
3
310
TanStack Start 技術選定の裏側 / Findy-Lunch-LT-TanStack-Start
iktakahiro
0
110
Cursorをチョッパヤインタビューライターにチューニングする方法 / how to tuning cursor for interview write
shuzon
2
120
MCPが変えるAIとの協働
knishioka
1
150
グループ ポリシー再確認 (2)
murachiakira
0
230
AI 코딩 에이전트 더 똑똑하게 쓰기
nacyot
0
540
製造業向けIoTソリューション提案資料.pdf
haruki_uiru
0
240
Асинхронная коммуникация в Go: от понятного к душному. Дима Некрасов, Otello, 2ГИС
lamodatech
0
2.1k
Kaigi Effect 2025 #rubykaigi2025_after
sue445
0
110
Dataverseの検索列について
miyakemito
1
190
GraphQLを活用したリアーキテクチャに対応するSLI/Oの再設計
coconala_engineer
0
210
Featured
See All Featured
Building Adaptive Systems
keathley
41
2.5k
How to train your dragon (web standard)
notwaldorf
91
6k
Why Our Code Smells
bkeepers
PRO
336
57k
StorybookのUI Testing Handbookを読んだ
zakiyama
30
5.7k
Build The Right Thing And Hit Your Dates
maggiecrowley
35
2.7k
Scaling GitHub
holman
459
140k
The Invisible Side of Design
smashingmag
299
50k
Build your cross-platform service in a week with App Engine
jlugia
230
18k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
19
1.2k
Fireside Chat
paigeccino
37
3.4k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
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