Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
2025.01.17_Sansan × DMM.swift
Search
RioFujimon
January 17, 2025
Programming
1.2k
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
2025.01.17_Sansan × DMM.swift
2025.01.17 に Sansan × DMM.swift で発表したスライド
RioFujimon
January 17, 2025
Transcript
43 slides
Pro SwiftUI ΛಡΜͰಘΒΕͨࣝ Sansan × DMM.swift 2025 / 01 /
17 ౻ ᣦੜ ʙ SwiftUI ͷಈ࡞ݪཧΛཧղ͢Δ ʙ
ࣗݾհ • ౻ᣦੜʢRio Fujimonʣ • Sansanגࣜձࣾ Eight Engineering Unit Mobile
Application άϧʔϓ • ৽ଔ 2 • Eight iOS ΞϓϦͷ։ൃΛ୲ • XʢTwitterʣ ͪ͜Β
SwiftUI Λཧղͯ͑ͯ͠·͔͢ʁ
͕ࣗॻ͍ͨ SwiftUI ίʔυͷ ಈ࡞ݪཧΛઆ໌Ͱ͖·͔͢ʁ
SwiftUI ͷίʔυಈ͍͔ͨΒྑ͠ 🙆 ʹͳͬͯ·ͤΜ͔ʁ
😨 ແཧ͔ͱ ࢥͬͨਓ͍ΔͷͰͳ͍Ͱ͠ΐ͏͔ʁ
ͦΜͳਓͷୈҰา
ࠓ͓͢͠Δ͜ͱ 1. SwiftUI ͷϨΠΞτϓϩηε 2. Parent View ͱ Child View
ͷؔ 3. View Size ͷमਖ਼ 4. View ͷϨΠΞτதཱੑ 5. View Identity ͷཧղ
SwiftUI ͷϨΠΞτϓϩηε
SwiftUI ͷϨΠΞτϓϩηε 1. Parent View ͕ Child View ʹαΠζΛఏҊ͢Δɻ 2.
Child View ɺParent View ͷఏҊใʹج͍ͮͯɺ αΠζΛબ͠ɺParent View બΛଚॏ͢Δɻ 3. Parent View ɺChild View Λ࠲ඪۭؒʹஔ͢Δɻ 💡ॏཁʢઈରཧղʣ
Parent View ͱ Child Viewͷؔ
ᶃ Parent View ͱ Child ViewͷؔΛճͰ͖Δʁ
ᶃ Parent View ͱ Child Viewͷؔ Parent View Child View
ᶄ Parent View ͱ Child ViewͷؔΛճͰ͖Δʁ
Parent View ͱ Child Viewͷؔ Parent View Child View ্هͷཧղ͚ͩͩͱɺෆे
🙅
Parent View ͱ Child Viewͷؔ Parent View Child View .frame()
ͷద༻ʹΑΓ Text Λϥοϓ͢Δ View Λੜ
Parent View ͱ Child ViewͷؔΛग़ྗ
Parent View ͱ Child ViewͷؔΛग़ྗ݁Ռ .frame() ͷద༻ʹΑΓɺModi f iedContent ͕ੜ͞ΕΔ
💡ॏཁʢઈରཧղʣ ݩͷ View Λ܁Γฦ͠มߋ͍ͯ͠ΔΘ͚Ͱͳ͘ɺ ݩͷViewΛมߋ͢Δ৽͍͠ View Λద༻͍ͯ͠Δ
ʢࢀߟʣModi f iedContent ͷఆٛ
.modi f ier() ͷద༻Ͱى͖͍ͯΔ͜ͱ .modi f ier() ͷద༻ = Modi
f iedContentΛੜ
View Size ͷमਖ਼
. f ixedSize() ͕ͲͷΑ͏ʹαΠζΛमਖ਼͍ͯ͠Δͷ͔આ໌Ͱ͖·͔͢ʁ . f ixedSize() Λద༻
SwiftUI ͰϨΠΞτΛܾఆ͢ΔͨΊͷ6ͭͷ 1. Minimum Width ͱ Minimum Height - View
͕ड͚ೖΕΔ࠷খݶͷ Space - ࠷খΑΓখ͍͞ Space ແࢹ͞Εɺ View ͕ఏҊ͞Εͨ Space ͔ΒΈग़͢ 2. Maximum Width ͱ Maximum Height - View ͕ड͚ೖΕΔ࠷େݶͷ Space - ࠷େΑΓେ͖͍ Space ແࢹ͞Εɺ Parent View Γͷ Space Ͱ Child View Λஔ͢Δ 3. Ideal Width ͱ Ideal Heightʢཧͷ෯ ͱ ཧͷߴ͞ʣ - View ͕Ήཧతͳ Space - ࠷খ͔Β࠷େͷൣғʹऩ·Δඞཁ͕͋Δ - ʢྫʣText ͷࣗવαΠζʢจࣈΛ1ߦʹऩΊΔͨΊʹదͨ͠ཧతͳ෯ͱߴ͞ʣ 💡ॏཁʢઈରཧղʣ
. f ixedSize() ͷ෦తͳಈ࡞ 30 × 100 30 × 100
Ideal Sizeɿ95 × 20 Ideal Size ΑΓ খ͍͞Մೳ Text ͷ Ideal Size
. f ixedSize() . f ixedSize() Λద༻ 💡. f ixedSize()
ɿཧαΠζΛݻఆαΠζʹঢ֨ͤ͞Δ
. f ixedSize() ͷ Image ͷద༻ ը໘෯ʹऩ·Βͳ͍ը૾ 300 × 100
ը૾ ͷ Ideal Size 300 × 100 Ideal Size ͘͠ Ideal Size ΑΓ খ͍͞Մೳ
View ͷϨΠΞτதཱੑ
Color.red ͷαΠζܾఆͷΈΛઆ໌Ͱ͖·͔͢ʁ .background(.red) ͱͯ͠ Color.red Λར༻
View ͷϨΠΞτதཱੑ ଞͷϏϡʔίϯςφͱͷΈ߹ΘͤʹΑͬͯॊೈʹࣗͷαΠζΛదԠͤ͞Δಛੑ ϨΠΞτதཱੑɺҎԼͷ 6 ͭͷ࣍ݩ ͕Өڹ͢Δ 1. Minimum Width
2. Minimum Height 3. Maximum Width 4. Maximum Height 5. Ideal Width 6. Ideal Height
Color.red ͷαΠζܾఆͷΈ ᶃ Parent View ͷαΠζΛड͚ೖΕΔ
Color.red ͷαΠζܾఆͷΈᶄ ը໘શମαΠζ ը໘શମαΠζ ϨΠΞτதཱ minWidth ͱ minHeight ϨΠΞτதཱ
࠷খҎ֎ͷ4ͭͷ Ideal Widthɿ95 Ideal Heightɿ20 Max Widthɿ95 Max Heightɿ20 300 200 Ideal Widthɿ300 Ideal Heightɿ200 Max Widthɿ95 Max Heightɿ20
View Identity ͷཧղ
View Identity View ΛҰҙʹࣝผ͠ɺ View ͷঢ়ଶදࣔ༰Λཧ͢ΔͨΊʹར༻͞ΕΔ 1. Explicit Identityʢ໌ࣔతͳΞΠσϯςΟςΟʣ •
ಛఆͷ View ʹରͯ͠ɺ.id() Λར༻ͯ͠໌ࣔతͳ Identity Λࢦఆ • ಈతͳσʔλΛѻ͏߹ʢྻͷ܁Γฦ͠ॲཧʣ • ಛఆͷ View Λࢀর͢Δඞཁ͕͋Δ߹ʢಛఆͷҐஔͷεΫϩʔϧॲཧʣ 2. Structural IdentityʢߏతͳΞΠσϯςΟςΟʣ • ίʔυͰͷஔߏʹج͍ͮͯɺࣗಈతʹੜ͞Εͨ Identity
View Identity ʹؔ࿈ͨ͠ SwiftUI ͷޡղ View ֊ʹมߋΛՃ͑Δͱɺ View πϦʔͷࠩൺֱΛߦ͍ɺԿ͕มߋ͞Ε͔ͨΛஅ͢Δ ※
View πϦʔͷࠩൺֱɿՃআ͞ΕͨཁૉΛಛఆ͢Δϓϩηε 🙅 🙆 SwiftUI ɺIdentity Λجʹ View Λࣝผ͠ɺঢ়ଶมߋΛޮతʹཧ͢Δ View ͷ Identity Λ໌ࣔతʹࢦఆ͢Δ͜ͱ͕ɺదͳߋ৽ͱ࠶ඳըͷ伴 Swift ͷίϯύΠϥɺView ͷίʔυΛߏங͢ΔࡍʹҎԼͷใΛશͯѲ ʢSubView, modi f ier, ݅จ, ܁Γฦ͠ॲཧʣ
View Identity ͱ View ͷ Life Cycle • View Identify
ɺView ͷ Life Cycle Λܾఆ • View Identity ͕ߏత·ͨ໌ࣔతʹมߋ͞ΕΔͱɺͦͷ View ഁغ͞ΕΔ • View Identity ཧɺView ͷঢ়ଶҡ࣋ޮతͳ࠶ඳըʹ݁͢Δ
ࠨӈͲͪΒͷ SwiftUI ͷίʔυʹ͕͋Δ͔આ໌Ͱ͖·͔͢ʁ
ࠨଆͷ SwiftUI ͷίʔυͷ View ͷߏΛग़ྗ݁Ռ _ConditionalContent ʹΑΓɺtrue ͱ false ͷ࣌Ͱɺ
2ͭͷผʑͷܕͱͯ͠ѻ͍ɺҟͳΔ Identity ͷ ExampleView ͱղऍ Toggle ͢Δ͝ͱʹɺ࠶ϨϯμϦϯά͞Εɺ View ͷঢ়ଶഁغ͞ΕΔ
ʢࢀߟʣ_ConditinalContent ͷॳظԽ xed /Applications/Your_Xcode_Name.app/Contents/Developer/Platforms/ iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/ Frameworks/SwiftUI.framework/Modules/SwiftUI.swiftmodule/x86_64-apple-ios- simulator.swiftinterface .swiftinterface Λ։͘͜ͱͰ֬ೝ͢Δ͜ͱ͕Ͱ͖Δ 👀
ӈଆͷ SwiftUI ͷίʔυͷ View ͷߏΛग़ྗ݁Ռ @ViewBuilder ͕ద༻͞Εͣɺ_ConditionalContent Λճආͯ͠ɺ AnyView ͱͳΓɺܕͱ֊ͷҐஔʹج͍ͮͯɺ
View ΛಉҰͷ Identity ͱͯ͠ཧ͍ͯ͠Δ Toggle ͯ͠ɺ࠶ϨϯμϦϯά͞Εͣɺ View ͷঢ়ଶอ࣋͞ΕΔ
SwiftUI ͷίʔυΛࡾ߲ԋࢉࢠΛར༻ͯ͠هड़ 1. AnyView → ExampleView ʹͳΓܕ໌֬ʹͳΔ 2. Structural IdentityʢߏతΞΠσϯςΟςΟʣ
͕ શͯॲཧΛ୲͏ঢ়ଶʹͳΔ ࡾ߲ԋࢉࢠΛར༻ͯ͠هड़͢Δ
ҎԼͷ༰ཧղͰ͖ͨͰ͠ΐ͏͔ʁ 1. SwiftUI ͷϨΠΞτϓϩηε 2. Parent View ͱ Child View
ͷؔ 3. View Size ͷमਖ਼ 4. View ͷϨΠΞτதཱੑ 5. View Identity ͷཧղ
ଞʹ༷ʑͳใ͕ܝࡌ͞Ε͍ͯΔͷͰɺಡΜͰΈ͍ͯͩ͘͞
Thank You For Listening
More Decks by RioFujimon
See All by RioFujimon
iOSDC2026登壇資料.pdf
riofujimon
0
240
Foundation Models を 活用するための Tips
riofujimon
1
470
実践 Realtime API 〜入力として音声データを扱う〜
riofujimon
1
120
Realtime API 入門
riofujimon
0
420
Let's learn code review
riofujimon
3
1.4k
Other Decks in Programming
See All in Programming
Vue.jsで作る空間解析アプリとCapacitorプラグインのData Bridge
hal_spidernight
1
180
Coding with AI: How to trust the storyteller (AWS Community Day Adria, Ljubljana 2026)
slobodan
0
150
疎結合とは何か?ソフトウェア設計における結合バランスについて考える #phpcon_niigata
kajitack
2
370
AI時代のIaC入門 〜なぜインフラをコードで管理したいのか?〜 / Introduction to IaC in the AI Era
akihisaikeda
6
1.6k
動画プレイヤーはなぜカクつくのか 〜Flutterのレンダリングとネイティブの境界を解剖する〜
naruogram
0
340
Scalaの型でマルチテナントの認可を守る
nextbeatdev
0
160
あなたの await、OS まで届いてる? strace で覗く JavaScript の非同期
hasutosasaki
1
2.4k
Kotlin JVM用に作られたライブラリのKMPを前提とした再設計
jsoizo
0
210
自作Discord音声botをLambda MicroVMsに移行した話 / Migrating My Discord Voice Bot to Lambda MicroVMs
akihisaikeda
1
380
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
220
LLM 101: Exploring LLMs, Starting with Tokens.
dalinaum
0
120
Secure Your Coding Agent Like It’s Malware (v1.5) 🇬🇧 @Code.talks 2026
richargh
0
190
Featured
See All Featured
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
410
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Building the Perfect Custom Keyboard
takai
2
960
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.7k
Rails Girls Zürich Keynote
gr2m
96
14k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
310
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.9k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
570
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
380
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
2
530
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
670