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
73
Python-intro-1
liushuaikobe
0
69
GitRadar——毕业论文答辩
liushuaikobe
0
180
NoSQL & MongoDB
liushuaikobe
0
150
Other Decks in Technology
See All in Technology
大規模プロダクトで実践するAI活用の仕組みづくり
k1tikurisu
5
1.7k
Building AI Applications with Java, LLMs, and Spring AI
thomasvitale
1
230
メッセージ駆動が可能にする結合の最適化
j5ik2o
8
1k
身近なCSVを活用する!AWSのデータ分析基盤アーキテクチャ
koosun
0
3.5k
都市スケールAR制作で気をつけること
segur
0
190
スタートアップの事業成長を支えるアーキテクチャとエンジニアリング
doragt
1
5.4k
How We Built a Secure Sandbox Platform for AI
flatt_security
1
110
なぜブラウザで帳票を生成したいのか どのようにブラウザで帳票を生成するのか
yagisanreports
0
160
Greenは本当にGreenか? - B/GデプロイとAPI自動テストで安心デプロイ
kaz29
0
120
PostgreSQL で列データ”ファイル”を利用する ~Arrow/Parquet を統合したデータベースの作成~
kaigai
0
150
組織の“見えない壁”を越えよ!エンタープライズシフトに必須な3つのPMの「在り方」変革 #pmconf2025
masakazu178
1
650
Android Studio Otter の最新 Gemini 機能 / Latest Gemini features in Android Studio Otter
yanzm
0
110
Featured
See All Featured
Visualization
eitanlees
150
16k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
192
56k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Faster Mobile Websites
deanohume
310
31k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
Into the Great Unknown - MozCon
thekraken
40
2.2k
How STYLIGHT went responsive
nonsquared
100
5.9k
Designing for Performance
lara
610
69k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.8k
Rebuilding a faster, lazier Slack
samanthasiow
84
9.3k
Embracing the Ebb and Flow
colly
88
4.9k
Building Adaptive Systems
keathley
44
2.8k
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