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
iOSDC2018.pdf
Search
Kishikawa Katsumi
September 02, 2018
Programming
18
7.5k
iOSDC2018.pdf
Good Practices for a Robust View Layout
iOSDC 2018
Kishikawa Katsumi
September 02, 2018
Tweet
Share
More Decks by Kishikawa Katsumi
See All by Kishikawa Katsumi
iOSDC 2024 SMBファイル共有をSwiftで実装する
kishikawakatsumi
1
160
Enhancing Applications with Accessibility API
kishikawakatsumi
3
3.2k
Mastering SwiftSyntax
kishikawakatsumi
4
5.3k
My SwiftData Review
kishikawakatsumi
7
1.4k
Swift Expression Macros: a practical introduction
kishikawakatsumi
3
1.8k
Xcode Cloudの評価
kishikawakatsumi
2
1.2k
Regular expressions basics/正規表現の基本
kishikawakatsumi
7
720
家のいろいろな数値を計測する
kishikawakatsumi
4
2.2k
GitHub Actionsでテストの結果をわかりやすく表示する
kishikawakatsumi
1
1k
Other Decks in Programming
See All in Programming
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
280
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
910
初めてDefinitelyTypedにPRを出した話
syumai
0
400
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
Click-free releases & the making of a CLI app
oheyadam
2
110
Better Code Design in PHP
afilina
PRO
0
120
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
600
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
880
TypeScriptでライブラリとの依存を限定的にする方法
tutinoko
2
660
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
200
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
693
190k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Practical Orchestrator
shlominoach
186
10k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Fireside Chat
paigeccino
34
3k
Thoughts on Productivity
jonyablonski
67
4.3k
Automating Front-end Workflow
addyosmani
1366
200k
Transcript
Good Practices for a Robust View Layout 2018.9.2
1. ϨΠΞτͳͥյΕΔͷ͔ 2. ʹରॲ͢ΔͨΊͷಓ۩ 2.1.Auto Layout 2.2.Storyboard 2.3.ϥΠϒϨϯμϦϯά 3. UIίϯϙʔωϯτΛςετ͢Δ
Agenda
What is a broken layout?
ը૾ɾσʔλٕज़આ໌ͷͨΊͷαϯϓϧͰ͢ɻ
ը૾ɾσʔλٕज़આ໌ͷͨΊͷαϯϓϧͰ͢ɻ
ը૾ɾσʔλٕज़આ໌ͷͨΊͷαϯϓϧͰ͢ɻ
ը૾ɾσʔλٕज़આ໌ͷͨΊͷαϯϓϧͰ͢ɻ
ը૾ɾσʔλٕज़આ໌ͷͨΊͷαϯϓϧͰ͢ɻ
ը૾ɾσʔλٕज़આ໌ͷͨΊͷαϯϓϧͰ͢ɻ
ϨΠΞτ͕յΕ͍ͯΔ ͜ͱʹؾͮ͘͜ͱ͍͠
- ಛఆͷঢ়ଶͷͱ͖͚ͩى͜Δ - ϩάΠϯɾະϩάΠϯͰදࣔ༰͕มΘΔ - λοϓεϫΠϓͷΞΫγϣϯͰը໘͕มΘΔ - σʔλͷྔʹΑΔ - ͞·͟·ͳΤϥʔ
- ਖ਼͠͞ͷఆ͕͍ٛ͠ - Ϋϥογϡ͢ΔΘ͚Ͱͳ͍ - ίϯϐϡʔλ͕ؒҧ͍ΛஅͰ͖ͳ͍ ͳͥյΕ͍ͯΔ͜ͱʹؾ͚ͮͳ͍͔
ؾͮ͘͜ͱ͕Ͱ͖ͯ ͙͜ͱ͞Βʹ͍͠
ը૾ɾσʔλٕज़આ໌ͷͨΊͷαϯϓϧͰ͢ɻ
ը૾ɾσʔλٕज़આ໌ͷͨΊͷαϯϓϧͰ͢ɻ
What is the problem?
- ঢ়ଶ͕ଟ͍ - μΠφϛοΫʹมԽ͢Δ - ࣮ߦ͢Δ·ͰΘ͔Βͳ͍ What is the problem
- ঢ়ଶΛݮΒ͠ - ੩తʹఆٛ͠ - ࣮ߦͤͣʹ֬ೝ͢Δ Λখ͘͢͞Δ
ಉ͡ͷΛ࡞Δํ๏͕ ৗʹෳଘࡏ͢Δ ѱ͍ΓํΛݮΒ͠ɺྑ͍ΓํΛ૿͢
(00% #"% 5FTUBCMF %FDMBSBUJWF 4UBUJD %ZOBNJD 4NBMM4JNQMF -BSHF$PNQMFY 'SBNF-BZPVU "VUP-BZPVU
9*#4UPSZCPBSE *OUFSGBDF#VJMEFS .BOVBM5FTU 6*4UBDL7JFX
Ξϯνύλʔϯ
- σόΠεΛఆ͢Δ - ඪ४UIͷαΠζΛԾఆ͢Δ Ξϯνύλʔϯ
σόΠεΛఆ͢Δ
σόΠεΛఆ͢Δ !
- ݅Λ૿͍͚ͯ͠ͳ͍ - if isIPhoneX { ͱॻ͍ͨͳΒɺiPhone Xͱͦ ΕҎ֎ͷσόΠεͰඞͣ֬ೝ͠ͳ͚ΕͳΒͳ ͘ͳΔ
- ৽͍͠σόΠε͕ൃച͞ΕͨΒʁ - ܧଓՄೳͳΈͰͳ͍ σόΠεΛఆ͍͚ͯ͠ͳ͍!
ඪ४UIͷαΠζΛԾఆ͢Δ
ඪ४UIͷαΠζΛԾఆ͢Δ !
ը૾ɾσʔλٕज़આ໌ͷͨΊͷαϯϓϧͰ͢ɻ
ը૾ɾσʔλٕज़આ໌ͷͨΊͷαϯϓϧͰ͢ɻ
ը૾ɾσʔλٕज़આ໌ͷͨΊͷαϯϓϧͰ͢ɻ
ը૾ɾσʔλٕज़આ໌ͷͨΊͷαϯϓϧͰ͢ɻ
ը૾ɾσʔλٕज़આ໌ͷͨΊͷαϯϓϧͰ͢ɻ
ը૾ɾσʔλٕज़આ໌ͷͨΊͷαϯϓϧͰ͢ɻ
- ඪ४UIͷαΠζݻఆͰͳ͍ - ࣮ߦ࣌ʹมΘΔ - มΘΒͳ͍ͱࢥ͍ͬͯΔͷҙ֎ͱมΘΔ - έʔεΛཏ͢Δ͜ͱ͕ࠔ ඪ४UIͷαΠζΛԾఆ͍͚ͯ͠ͳ͍!
Safe Area (Top/Bottom Layout Guide)͔Β૬ରతʹߟ͑Δ
Safe Area (Top/Bottom Layout Guide)͔Β૬ରతʹߟ͑Δ
Safe Area (Top/Bottom Layout Guide)͔Β૬ରతʹߟ͑Δ - Safe Areaʹ͚Δ͔ͦ͏Ͱͳ͍ͷ͔ - جຊతʹ͜Ε͚ͩ
- ͜ΕΛͦΕͧΕͷϏϡʔͰஅ͢Δ
Good/Bad Practice
- AutoLayout - Storyboard ʹରॲ͢ΔͨΊͷπʔϧ
Frame LayoutΑΓ Auto Layout
- Auto Layout GOOD - Frame Layout BAD
- Auto Layout (or Alt-Auto Layout) GOOD - Frame Layout
BAD
Storyboard (Interface Builder)Λ ׆༻͢Δ
Good
None
None
None
- Interface BuilderΛ׆༻͢Δ - Auto LayoutͷΤϥʔΛڭ͑ͯ͘ΕΔ - ࣮ߦͤͣʹ͞·͟·ͳঢ়ଶΛ֬ೝͰ͖Δ - @IBDesignable/@IBInspectable͕ศར
Good Practice
Auto Layoutͷ੍Λ Storyboard/XIBͰ࡞͢Δ
Auto Layoutͷ੍Λ Storyboard/XIBͰ࡞͢Δ
ը૾ɾσʔλٕज़આ໌ͷͨΊͷαϯϓϧͰ͢ɻ
Q. Auto Layoutͷ੍Λ ίʔυͰॻ͘͜ͱͷԿ͕͍͠ͷ͔
A. ੍͕૬ޓʹӨڹ͢ΔͨΊ
None
None
None
None
None
None
None
None
None
None
None
None
None
4T
None
None
None
- ϝϞϦ͕Γͳ͘ͳΔ ίʔυͰॻ͘ΑΓStoryboard
એݴతʹهड़͢Δ
None
None
None
Use UIStackView
Use UIStackView
None
None
τϧπϝUIStackView - ͯ͢ͷϏϡʔΛUIStackViewʹ٧Ίͯɺ isHiddenΛΓସ͑Δ͚ͩ - Ϛʔδϯ͕ҰఆͰͳ͍߹ϚʔδϯΛ࣋ͭϏϡʔ Λ֎ଆʹ࣋ͭ
ࣅͨΑ͏ͳϏϡʔͰ߲ͷ૿ݮ͕͋Δͱ͖
ࣅͨΑ͏ͳϏϡʔͰ߲ͷ૿ݮ͕͋Δͱ͖
Paging /w UIScrollView ը૾ɾσʔλٕज़આ໌ͷͨΊͷαϯϓϧͰ͢ɻ
UICollection/TableView vs UIStackView ը૾ɾσʔλٕज़આ໌ͷͨΊͷαϯϓϧͰ͢ɻ
Animation ը૾ɾσʔλٕज़આ໌ͷͨΊͷαϯϓϧͰ͢ɻ
ΞχϝʔγϣϯʹΑΔϨΠΞτͷӨڹ - ΞχϝʔγϣϯʹΑͬͯผͷϏϡʔͷҐஔΛม͑ Δ͔Ͳ͏͔ʢྫ: ԡ͠ग़͢ʣ - ผͷϏϡʔΛԡ͠ग़ͨ͠Γ͠ͳ͍ͳΒɺ CGAffineTransform͕͑Δ
CGAffineTransformʹΑΔΞχϝʔγϣϯ
CGAffineTransformʹΑΔΞχϝʔγϣϯ
ಈతͳ༰Λ੩తʹఆٛ͢Δ - UIStackViewΛ׆༻͢Δ - τϧπϝ - ߲ͷ૿ݮ - εΫϩʔϧ/ϖʔδϯά -
CGAffineTransformʹΑΔΞχϝʔγϣϯ
- Auto LayoutίʔυͰॻ͘ΑΓStoryboard/XIB - ঢ়ଶΛݮΒ͢ - ੩తʹఆٛ͢Δ - ಈతʹ੍Λมߋ͠ͳ͍ Good
Practice
Grouping
άϧʔϐϯά͢Δͱ੍ͷ͕ؔ؆୯ʹͳΔ
άϧʔϐϯά͢Δͱ੍ͷ͕ؔ؆୯ʹͳΔ
άϧʔϐϯά͢Δͱ੍ͷ͕ؔ؆୯ʹͳΔ
άϧʔϐϯά͢Δͱ੍ͷ͕ؔ؆୯ʹͳΔ
άϧʔϐϯά͢Δͱ੍ͷ͕ؔ؆୯ʹͳΔ
άϧʔϐϯά͢Δͱ੍ͷ͕ؔ؆୯ʹͳΔ
άϧʔϐϯά͢Δͱ੍ͷ͕ؔ؆୯ʹͳΔ
- ׂ౷࣏ - ৗʹ̎ͭͷϏϡʔͱSuper Viewͷؔͱͯ͠ߟ͑ ΒΕΔ - Γ͗͢ېʢϝϞϦ͕Γͳ͘ͳΔʣ άϧʔϐϯά͢Δͱ੍ͷ͕ؔ؆୯ʹͳΔ
ύϑΥʔϚϯε͕ؾʹͳΔʁ
- ྆ํΛ༏ઌ͢Δ͜ͱͰ͖ͳ͍ - ઈରతͳਖ਼ղͳ͍ - ৗʹܭଌ͢͠ - ຊʹʹͳΔͱ͜Ζ͚ͩ - ηΦϦʔͱͯ͠ɺಡΈ͢͞Λ༏ઌ͢Δ
ύϑΥʔϚϯεͷৗʹτϨʔυΦϑ
- Best Practice!! - ςελϒϧʹ͢Δʹґଘ͕গͳ͘ͳΔɺ͕খ ͘͞ͳΔɺetc - ݸʑͷίϯϙʔωϯτ͕ਖ਼͚͠Εશମ͕ਖ਼͍͠ ͕֬ߴ͍ ςελϒϧʹ͢Δ
Folio UI Collection https://github.com/folio-sec/Folio-UI-Collection
Folio UI Collection $POUBJOFE#VUUPO 0VUMJOFE#VUUPO 5FYU#VUUPO 5BH-BCFM $POUBJOFS -BCFM 4VCNJTTJPO4UBUVT#VUUPO
https://github.com/folio-sec/Folio-UI-Collection
- ঢ়ଶΛݮΒ͢ - ੩తʹఆٛ͢Δ - ࣮ߦͤͣʹ֬ೝ͢ΔखஈΛ૿͢ - ςελϒϧΛࢦ͢ Summary
None