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
uhooiさん発ランダムタスクにチャレンジしよう!
Search
野瀬田 裕樹
August 10, 2026
Programming
13
0
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 野瀬田 裕樹
ViewModelって200種類あんねん
yuukiw00w
0
12
Validate your App Intents adoption with AppIntentsTesting
yuukiw00w
0
9
App Intentsを実装しよう
yuukiw00w
0
9
iOS26時代の新規アプリ開発
yuukiw00w
0
250
Swift ConcurrencyでよりSwiftyに
yuukiw00w
0
350
Human Interface Guidelines 2
yuukiw00w
0
79
AI前提で考えるiOSアプリのモダナイズ設計
yuukiw00w
0
290
HIG学習用スライド
yuukiw00w
0
200
FlutterKaigi 2025: What is iOS Assistive Access? UI considerations for Flutter
yuukiw00w
0
64
Other Decks in Programming
See All in Programming
Apache Hive: そしてCloud Native Lakehouseへ
okumin
1
210
the container ship “Apple Silicon”@WWDC26 Recap -Japan-\(region).swift
shingangan
0
110
PHP に部分適用が来るぞ!……ところで何それ?おいしいの? #phpcon / phpcon-2026
shogogg
0
600
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
860
Apache Hive: Toward a Cloud Native Lakehouse
okumin
0
180
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
310
PostgreSQL 18で考えるUUID主キー
kazuhiro1982
0
460
仕様駆動開発の消費期限
watany
16
7.2k
AI時代に設計が 最大の生産性レバーになる 意図駆動開発とデータを消さない設計|Don't Delete Your Data or Your Intent — Design as the Deepest Lever in the AI Era
tomohisa
1
730
プロポーザルを書いてもらう
pvcresin
0
290
『コードを書く以外の』エンジニアリング〜課金基盤移行プロジェクト推進のためのTips4選
yuriko1211
0
590
全PRの83%がAIレビューだけでマージできるようになった開発組織はその後どうなったか
athug
1
1.5k
Featured
See All Featured
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
210
Unsuck your backbone
ammeep
672
58k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.2k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
260
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
340
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
540
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
270
Ruling the World: When Life Gets Gamed
codingconduct
0
290
BBQ
matthewcrist
89
10k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
230
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とか欲しい
まとめ • たまに時間あったらこういうお題にチャレンジしても面白いよね • みんなも自分なりの回答をポストしてみよう!