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
組織成長を加速させるオンボーディングの取り組み
sudoakiy
2
160
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
300k
Lexical Analysis
shigashiyama
1
150
Lambdaと地方とコミュニティ
miu_crescent
2
370
iOSチームとAndroidチームでブランチ運用が違ったので整理してます
sansantech
PRO
0
140
テストコード品質を高めるためにMutation Testingライブラリ・Strykerを実戦導入してみた話
ysknsid25
7
2.6k
これまでの計測・開発・デプロイ方法全部見せます! / Findy ISUCON 2024-11-14
tohutohu
3
370
【令和最新版】AWS Direct Connectと愉快なGWたちのおさらい
minorun365
PRO
5
750
EventHub Startup CTO of the year 2024 ピッチ資料
eventhub
0
120
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
220
CysharpのOSS群から見るModern C#の現在地
neuecc
2
3.4k
Can We Measure Developer Productivity?
ewolff
1
150
Featured
See All Featured
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Gamification - CAS2011
davidbonilla
80
5k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Bash Introduction
62gerente
608
210k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
How STYLIGHT went responsive
nonsquared
95
5.2k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
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