SwiftUI: .clipped()外をインタラクティブ不可にする

p0dee
2 min readJun 12, 2020

--

以前試みた、offset指定可能なスクロールビューの実装の続きで得た気づき。

SwiftUIで自身のboundsで表示内容をclipするには、.clipped()を使用する。

すると表示はclipされるが、clipしたビューに追加したジェスチャーは、clip領域(すなわちbounds)外でも反応してしまう。本当は、clip外からのドラッグには反応して欲しくないのだ。

以前、透明な領域もタップ可能にする方法として紹介した、.contentShape(_:eoFill:)が今回も使ってみた。

clip外でのジェスチャには反応せず、一見解決できたかのように思えたが、ドラッグ速度など条件によっては、bounds内でジェスチャが効いてしまうことがあった。

引き続き調査中、、

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