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
120
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
68
Python-intro-1
liushuaikobe
0
63
GitRadar——毕业论文答辩
liushuaikobe
0
170
NoSQL & MongoDB
liushuaikobe
0
140
Other Decks in Technology
See All in Technology
2時間で300+テーブルをデータ基盤に連携するためのAI活用 / FukuokaDataEngineer
sansan_randd
0
160
夏休みWebアプリパフォーマンス相談室/web-app-performance-on-radio
hachi_eiji
0
230
20250807 Applied Engineer Open House
sakana_ai
PRO
2
470
文字列の並び順 / String Collation
tmtms
1
100
Google Cloud で学ぶデータエンジニアリング入門 2025年版 #GoogleCloudNext / 20250805
kazaneya
PRO
22
5.5k
Rubyの国のPerlMonger
anatofuz
3
740
✨敗北解法コレクション✨〜Expertだった頃に足りなかった知識と技術〜
nanachi
1
740
React Server ComponentsでAPI不要の開発体験
polidog
PRO
0
310
データモデリング通り #2オンライン勉強会 ~方法論の話をしよう~
datayokocho
0
180
ロールが細分化された組織でSREと協働するインフラエンジニアは何をするか? / SRE Lounge #18
kossykinto
0
220
Delegate authentication and a lot more to Keycloak with OpenID Connect
ahus1
0
220
Backlog AI アシスタントが切り開く未来
vvatanabe
1
140
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
512
110k
YesSQL, Process and Tooling at Scale
rocio
173
14k
Navigating Team Friction
lara
188
15k
[RailsConf 2023] Rails as a piece of cake
palkan
56
5.8k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
36
2.5k
Documentation Writing (for coders)
carmenintech
73
5k
Writing Fast Ruby
sferik
628
62k
Agile that works and the tools we love
rasmusluckow
329
21k
Why Our Code Smells
bkeepers
PRO
338
57k
The Art of Programming - Codeland 2020
erikaheidi
54
13k
Making the Leap to Tech Lead
cromwellryan
134
9.5k
How to train your dragon (web standard)
notwaldorf
96
6.2k
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