Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Auto-Layout.pdf
Shuai Liu
September 22, 2015
Technology
2
85
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
41
Python-intro-1
liushuaikobe
0
38
GitRadar——毕业论文答辩
liushuaikobe
0
110
NoSQL & MongoDB
liushuaikobe
0
76
Other Decks in Technology
See All in Technology
Red Hat Summit 2022 の概要とオススメセッションのご紹介
rhpej
1
190
Devに力を授けたいSREのあゆみ / SRE that wants to empower developers
tocyuki
3
380
20220510_簡単にできるコスト異常検出(Cost Anomaly Detection) /jaws-ug-asa-cost-anomaly-detection-20220510
emiki
2
290
ZOZOTOWNのProduction Readiness Checklistと信頼性向上の取り組み / Improvement the reliability of ZOZOTOWN with Production Readiness Checklist
akitok_
4
1.1k
Who owns the Service Level?
chaspy
5
550
AWSの基礎を学ぼうで学んだ9種類のDBを勝手にふりかえる
98lerr
1
690
僕の Microsoft Teams (+α) 便利技紹介 2022年春
taichinakamura
0
1.7k
Nutanix_Meetup_20220511
keigotomomatsu
0
130
New Features in C# 10/11
chack411
0
340
A Conditional Point Diffusion-Refinement Paradigm for 3D Point Cloud Completion
takmin
0
120
Okta Identity Engineってどうよ?
tatsumin39
0
270
AWS CLI入門_20220513
suzakiyoshito
0
2.9k
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
103
16k
KATA
mclloyd
7
8.5k
The Mythical Team-Month
searls
208
39k
Designing for humans not robots
tammielis
241
23k
How STYLIGHT went responsive
nonsquared
85
3.9k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
15
900
Put a Button on it: Removing Barriers to Going Fast.
kastner
56
2.3k
Web Components: a chance to create the future
zenorocha
303
40k
jQuery: Nuts, Bolts and Bling
dougneiner
56
6.4k
How to train your dragon (web standard)
notwaldorf
57
3.8k
GraphQLとの向き合い方2022年版
quramy
16
8k
Designing Experiences People Love
moore
130
22k
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