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
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
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1k
OWASP Top 10:2025 リリースと 少しの日本語化にまつわる裏話
okdt
PRO
3
490
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
42k
Digitization部 紹介資料
sansan33
PRO
1
6.8k
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
3.8k
AI駆動PjMの理想像 と現在地 -実践例を添えて-
masahiro_okamura
1
100
Stately
mu7889yoon
1
110
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
13k
Cosmos World Foundation Model Platform for Physical AI
takmin
0
590
入社1ヶ月でデータパイプライン講座を作った話
waiwai2111
1
260
10Xにおける品質保証活動の全体像と改善 #no_more_wait_for_test
nihonbuson
PRO
2
220
仕様書駆動AI開発の実践: Issue→Skill→PRテンプレで 再現性を作る
knishioka
2
610
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.2k
Chasing Engaging Ingredients in Design
codingconduct
0
110
Automating Front-end Workflow
addyosmani
1371
200k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
730
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.9k
Building Applications with DynamoDB
mza
96
6.9k
Crafting Experiences
bethany
1
48
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
410
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
160
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.4k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
910
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