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
58
Python-intro-1
liushuaikobe
0
52
GitRadar——毕业论文答辩
liushuaikobe
0
160
NoSQL & MongoDB
liushuaikobe
0
98
Other Decks in Technology
See All in Technology
マルチプロダクトな開発組織で 「開発生産性」に向き合うために試みたこと / Improving Multi-Product Dev Productivity
sugamasao
1
310
Python(PYNQ)がテーマのAMD主催のFPGAコンテストに参加してきた
iotengineer22
0
500
DynamoDB でスロットリングが発生したとき_大盛りver/when_throttling_occurs_in_dynamodb_long
emiki
1
420
ISUCONに強くなるかもしれない日々の過ごしかた/Findy ISUCON 2024-11-14
fujiwara3
8
870
VideoMamba: State Space Model for Efficient Video Understanding
chou500
0
190
OS 標準のデザインシステムを超えて - より柔軟な Flutter テーマ管理 | FlutterKaigi 2024
ronnnnn
0
180
Can We Measure Developer Productivity?
ewolff
1
150
Exadata Database Service on Dedicated Infrastructure(ExaDB-D) UI スクリーン・キャプチャ集
oracle4engineer
PRO
2
3.2k
強いチームと開発生産性
onk
PRO
35
11k
TypeScriptの次なる大進化なるか!? 条件型を返り値とする関数の型推論
uhyo
2
1.7k
CysharpのOSS群から見るModern C#の現在地
neuecc
2
3.5k
The Rise of LLMOps
asei
7
1.7k
Featured
See All Featured
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Embracing the Ebb and Flow
colly
84
4.5k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
How to Ace a Technical Interview
jacobian
276
23k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
Designing Experiences People Love
moore
138
23k
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