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
79
Python-intro-1
liushuaikobe
0
74
GitRadar——毕业论文答辩
liushuaikobe
0
180
NoSQL & MongoDB
liushuaikobe
0
170
Other Decks in Technology
See All in Technology
大規模サービスにおける レガシーコードからReactへの移行
magicpod
1
120
AI時代にエンジニアはどう成長すれば良いのか?
recruitengineers
PRO
1
120
JAWS DAYS 2026 CDP道場 事前説明会 / JAWS DAYS 2026 CDP Dojo briefing document
naospon
0
130
Databricksアシスタントが自分で考えて動く時代に! エージェントモード体験もくもく会
taka_aki
0
310
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
44k
20260305_【白金鉱業】分析者が地理情報を武器にするための軽量なアドホック分析環境
yucho147
0
130
マネージャー版 "提案のレベル" を上げる
konifar
17
12k
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.4k
ブラックボックス観測に基づくAI支援のプロトコルのリバースエンジニアリングと再現~AIを用いたリバースエンジニアリング~ @ SECCON 14 電脳会議 / Reverse Engineering and Reproduction of an AI-Assisted Protocol Based on Black-Box Observation @ SECCON 14 DENNO-KAIGI
chibiegg
0
140
DX Improvement at Scale
ntk1000
2
250
Digitization部 紹介資料
sansan33
PRO
1
7k
Introduction to Sansan, inc / Sansan Global Development Center, Inc.
sansan33
PRO
0
3k
Featured
See All Featured
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.7k
Site-Speed That Sticks
csswizardry
13
1.1k
How to build a perfect <img>
jonoalderson
1
5.2k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
760
4 Signs Your Business is Dying
shpigford
187
22k
Building Applications with DynamoDB
mza
96
6.9k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Darren the Foodie - Storyboard
khoart
PRO
3
2.7k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
190
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.1k
Why Our Code Smells
bkeepers
PRO
340
58k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
190
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