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
76
Python-intro-1
liushuaikobe
0
72
GitRadar——毕业论文答辩
liushuaikobe
0
180
NoSQL & MongoDB
liushuaikobe
0
170
Other Decks in Technology
See All in Technology
SREチームをどう作り、どう育てるか ― Findy横断SREのマネジメント
rvirus0817
0
320
Cosmos World Foundation Model Platform for Physical AI
takmin
0
940
ファインディの横断SREがTakumi byGMOと取り組む、セキュリティと開発スピードの両立
rvirus0817
1
1.5k
AI駆動開発を事業のコアに置く
tasukuonizawa
1
270
Digitization部 紹介資料
sansan33
PRO
1
6.8k
Data Hubグループ 紹介資料
sansan33
PRO
0
2.7k
Claude_CodeでSEOを最適化する_AI_Ops_Community_Vol.2__マーケティングx_AIはここまで進化した.pdf
riku_423
2
600
顧客との商談議事録をみんなで読んで顧客解像度を上げよう
shibayu36
0
260
Webhook best practices for rock solid and resilient deployments
glaforge
2
300
CDK対応したAWS DevOps Agentを試そう_20260201
masakiokuda
1
350
Bill One 開発エンジニア 紹介資料
sansan33
PRO
5
17k
データの整合性を保ちたいだけなんだ
shoheimitani
8
3.2k
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.2k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3k
Context Engineering - Making Every Token Count
addyosmani
9
660
Making the Leap to Tech Lead
cromwellryan
135
9.7k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
940
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Writing Fast Ruby
sferik
630
62k
Ethics towards AI in product and experience design
skipperchong
2
200
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
Prompt Engineering for Job Search
mfonobong
0
160
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
0
2.3k
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