SwiftUI: 影付きボタンの実装

p0dee
1 min readMay 27, 2020

昨日のボタンネタに関連して。

SwiftUIのUIKitと比較して良いところのひとつは、デザインの作り込みが容易に行えること。ビューの輪郭線や塗りグラデーション、影の描画をUIKitよりも遥かにシンプルに実装できる点だと感じている。

例えば、影付きボタン、ただ影を描画するだけでなく、押下状態に応じた影を描画し分けることも容易に実現することができる。

ButtonStyleconfiguration.isPressedによって押下状態を取得し、それに応じて影の各プロパティを指定するのがポイント。

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response