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
Dive into lazy stacks and scrolling with SwiftUI
Search
ibuki
June 26, 2026
Programming
68
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Dive into lazy stacks and scrolling with SwiftUI
ibuki
June 26, 2026
More Decks by ibuki
See All by ibuki
APIの遅延実行で崩れるユーザー体験をどう守る?
ibuibukiki
0
4
Other Decks in Programming
See All in Programming
phperだってパンチカードでコーディングしたい
o0h
PRO
0
340
Railsのためのパスキー実践入門 〜マルチテナントSaaSでの意思決定〜
utakaha
2
650
Unity6 URPによる海底をテーマにしたVJシステムの解説 | Unity Shader 完全に理解した 勉強会
gam0022
0
370
Verilogで学ぶCPU自作入門
uyuki234
8
4.1k
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
380
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.5k
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
0
1.5k
残高管理から台帳サービスへの進化
artoy
1
200
Vue Fes Japan の “作る側”に関わってみて
naokihaba
0
160
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
210
[JA] Domain Modeling with Vanilla Rails: 「操作」から再考するRailsの設計論
yasaichi
2
400
Kotlinの15年とServer-Side Kotlin
n_takehata
1
150
Featured
See All Featured
Thoughts on Productivity
jonyablonski
76
5.4k
Everyday Curiosity
cassininazir
0
360
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
550
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
69
67k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
For a Future-Friendly Web
brad_frost
184
10k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Designing Powerful Visuals for Engaging Learning
tmiket
1
610
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
260
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
So, you think you're a good person
axbom
PRO
2
2.2k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
600
Transcript
Dive into lazy stacks and scrolling with SwiftUI 集まれSwift好き!Swift愛好会スピンオフ WWDC26セッション要約会 🔰初談義
ibuki (@ibuibukiki) ・LINEヤフー株式会社 (新卒2年⽬) ・Yahoo!フリマのiOSエンジニア ・ユーザー体験にこだわりたい! Swift愛好会初参加です!
このセッションを選んだ理由 Yahoo!フリマには、 ・⾃分が出品している商品を⼀覧で⾒る画⾯ ・まとめ買いできる商品を⼀覧から探す画⾯ など、商品情報を並べるスクロール画⾯がたくさんある UIKitからSwiftUIへの移⾏が進む中 「より良いスクロール体験を実現するための⽅法を学びたい」 と考えた
VStack vs LazyVStack LazyVStack の⽅がメモリ効率がよく、 ⼤量のデータを描画するのに適している VStack すべてのViewを⽣成 LazyVStack 表⽰に必要なViewだけを⽣成
LazyVStack の描画処理 LazyVStack全体 View この端末の画⾯に 描画
上から順番にViewをレイアウト LazyVStack の描画処理
LazyVStack の描画処理 上から順番にViewをレイアウト 画⾯の領域が埋まるとストップ
画⾯をスクロールすると LazyVStack の描画処理
画⾯をスクロールすると またViewを追加し、表⽰領域を埋める LazyVStack の描画処理
LazyVStack が知っていること 正確に知っているのは ・表⽰中のView ・その⾼さ それ以外は推定して動いている ここだけ
LazyVStack が推定していること 全体の⾼さ 表⽰されているViewの平均の⾼さ × Viewの数 スクロール位置 (OffSet) スクロール →
今のViewの相対位置を取得 → 推定値を更新 (繰り返し)
Appleが伝えたかったこと LazyStackの推定に依存しないこと LazyStackの推定を壊さないこと
Appleが勧める設計 1. OffSetの推定に頼らないこと 2. Viewの数を途中で変えないこと 3. Viewの⾼さを途中で変えないこと 4. onAppearに初期化処理を⼊れないこと
1. Offsetの推定に頼らないこと 「100ptスクロールしたらボタンを消す」 OK: 絶対位置ではなく、Viewの相対位置を使う contentOffsetは推定値なので挙動が不安定になってしまう
2. Viewの数を途中で変えないこと 「ここのViewは条件を満たす時だけ出したい」 OK: LazyStackに渡す前にフィルターをかける Viewの数が変わるとindexがズレるため、推定とずれてしまう
3. Viewの⾼さを途中で変えないこと 「テキストの⻑さに合わせて画像の⾼さも変えたい」 OK: レイアウトは init() 時に決める 描画してからレイアウトをやり直すので推定とずれてしまう
4. onAppearに初期化処理を⼊れないこと LazyStackは表⽰前のViewを事前に評価するPrefetch を⾏っており、 これによって滑らかなスクロールが可能になる • body: 表⽰前に評価されることがある • onAppear:
表⽰後に呼ばれる 表⽰前にできる準備を onAppear に書くと Prefetch を活かせない 表⽰前にできる初期化は init で⾏う
まとめ ・LazyStackが正確に知っているのは画⾯内のViewだけ ・全体の⾼さもスクロール位置も推定しているだけで、 完全に正確ではない ・「推定に依存しない」「推定を壊さない」を意識することで 安定したスクロール体験を維持できる