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
uhooiさん発ランダムタスクにチャレンジしよう!
Search
野瀬田 裕樹
August 10, 2026
Programming
79
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
uhooiさん発ランダムタスクにチャレンジしよう!
集まれSwift好き!Swift愛好会 vol.80 @ DeNA
https://love-swift.connpass.com/event/311304/
野瀬田 裕樹
August 10, 2026
More Decks by 野瀬田 裕樹
See All by 野瀬田 裕樹
速習iPhone Duo対応
yuukiw00w
2
880
App Storeの外へ──日本のiOSサイドローディング入門 for iOSDC Japan 2026
yuukiw00w
0
270
ネイティブiOSアプリだからできること
yuukiw00w
0
40
野瀬田とSwift愛好会
yuukiw00w
0
38
ViewModelって200種類あんねん
yuukiw00w
0
59
Validate your App Intents adoption with AppIntentsTesting
yuukiw00w
0
57
App Intentsを実装しよう
yuukiw00w
0
58
iOS26時代の新規アプリ開発
yuukiw00w
0
280
Swift ConcurrencyでよりSwiftyに
yuukiw00w
0
400
Other Decks in Programming
See All in Programming
モジュールの視点からSwiftを読み解く #iosdc
s_shimotori
0
220
海上で動くGoサーバー: goroutineとchannelでさばく航行データストリーム
atsuki_seo
0
990
The Rails Doctrine Decade
koic
2
410
[2026-09-26]空論ジェネリックプロセス~テスト資産とAIで紡ぐ、再現可能なパフォーマンスチューニングの話~
tosite
0
230
スマート反転とウェブアクセシビリティ
camiha
0
220
App Intentsのビルドプロセスを支える技術
kntkymt
0
470
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
5
9k
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
170
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
420
Java 27新機能 / Java 27 new features
kishida
2
180
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
590
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
4.3k
Featured
See All Featured
The Spectacular Lies of Maps
axbom
PRO
1
1k
Product Roadmaps are Hard
iamctodd
55
13k
Code Review Best Practice
trishagee
74
20k
First, design no harm
axbom
PRO
2
1.3k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
910
Git: the NoSQL Database
bkeepers
PRO
432
67k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
200
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
530
A designer walks into a library…
pauljervisheath
211
25k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
It's Worth the Effort
3n
188
29k
Scaling GitHub
holman
464
140k
Transcript
uhooiさん発ランダムタスクに チャレンジしよう! 野瀬田 裕樹
野瀬田 裕樹(@ynoseda) DMM.com アプリ開発室所属
uhooiさん • uhooiさんのことはみんな知ってる前提なので話しません • たまにuhooiさんのXからランダムにアプリ開発のお題が流れてくることがあり ます • 今日はたまたま目についたそれをやった話
お題1:ScrollViewの背景色を良い感じにしたい!
やりたいこと • ScrollViewで引っ張ったとき、コンテンツ領域の外ではScrollView自体の backgroundが見える • このbackgroundの色をコンテンツの色と同じにしたい • 上から下に引っ張ったときは、コンテンツの上の方の色と同じにしたい • 逆の場合はコンテンツの下の方の色と同じにしたい
お題1の解答編
お題1の解答編 - 概要 • コンテンツのy座標に連動するpositionを保持する • ScrollViewの背景色で、このpositionより上の領域はコンテンツの上の方の色 にする • 逆に下の方の領域はコンテンツの下の方の色にする
お題1の解答編 - コンテンツのy座標に連動させる private struct ScrollContentViewMinYPreferenceKey: PreferenceKey { static var
defaultValue: [CGFloat] = [0] static func reduce(value: inout [CGFloat], nextValue: () -> [CGFloat]) { value.append(contentsOf: nextValue()) } }
お題1の解答編 - コンテンツのy座標に連動させる ScrollView { content().overlay { GeometryReader { proxy
in Color.clear.preference( key: ScrollContentViewMinYPreferenceKey.self, value: [proxy.frame(in: .global).minY] ) } } }.onPreferenceChange(ScrollContentViewMinYPreferenceKey.self) { value in scrollContentViewMinY = value[0] }
お題1の解答編 - 連動したpositionより上だけ色を変更 .background { VStack(spacing: 0) { topBackgroundColor.frame(height: max(scrollContentViewMinY,
0)) bottomBackgroundColor.frame(height: scrollViewHeight - scrollContentViewMinY) }.ignoresSafeArea() }.overlay { GeometryReader { proxy in Color.clear.onAppear { scrollViewHeight = proxy.frame(in: .global).height } }.ignoresSafeArea() }
お題1の解答編 - 結果 • これで良い感じになった! • https://x.com/ynoseda/status/1737120393960558947?s=20 • 補足 ◦
別に基準値はminYじゃなくてもmaxYでもなんでもいいです ▪ コンテンツの裏のどこかのpositionで切り替わればいいので
お題2:スクロールの境目でボタンの色を変えたい!
やりたいこと • ScrollViewでスクロールしたとき、ナビゲーションバーが透明だとボタンとコン テンツの色が重なって見辛くなることがある • Appleの公式のアプリだと背景色に合わせてボタンの色が良い感じに変化して いる • これを実現したい
お題2の解答編
お題2の解答編 - 概要 • スクロールするごとに今のwindow(UIView)からUIImageに変換する • このとき、ボタンのframeを使ってボタン部分のみを切り出す • 切り出すときにボタンの形状にあたる丸を書いてその外側だけ書き出すよう にする
• ボタンの周りのUIImageが得られるのでそれが明るいか判定する
お題2の解答編 - コード • https://gist.github.com/yuukiw00w/0972b4fd33a08fe774228ebaa592558e • 実装は↑にあるが、汚すぎるので参考までに • https://x.com/ynoseda/status/1741515297054744844?s=20 •
補足 ◦ パフォーマンス低そうな気がするので実運用に耐えられるかは微妙 ◦ 階層は違うけど裏にいるViewの色を判定するAPIとか欲しい
まとめ • たまに時間あったらこういうお題にチャレンジしても面白いよね • みんなも自分なりの回答をポストしてみよう!