5

Apple recently announced that half sheets will soon be feasible in SwiftUI with the addition of the .presentationDetents(detents: Set<PresentationDetent>) modifier.

Sadly, this still seems to block any user interaction with the views behind the sheet.

Is there any way to allow user interaction with the views behind the sheet?

pinglock
  • 982
  • 2
  • 12
  • 30
  • Interested in a potential workaround too — Apple's system views are really hard to customize. In the meantime maybe try my library https://github.com/aheze/SplitSheet – aheze Jun 20 '22 at 23:11
  • The adaptive controls in UIKt has the undimmed identifier option. – lorem ipsum Jun 20 '22 at 23:28
  • 1
    They do not only cover behind view with dimmed view (which intercepts taps) but also disabled behind view interactivity completely, so making foreground cover as clear colored would not help. (It seems they foreseen our desire to do that and prevented it ;) ). It's remained only to wait for public API that configures this in future versions, or use custom solutions. – Asperi Jun 21 '22 at 05:21

2 Answers2

10

With the latest Xcode 14.3 Beta and iOS 16.4 Beta you can finally do this with .sheet using presentationBackgroundInteraction view modifier:

.presentationDetents([.height(100), .medium, .large])
.presentationBackgroundInteraction(
    .enabled(upThrough: .medium)
)

This will enable interaction with view behind the sheet when the sheet is in .height(100) or .medium detents.

Marius Kažemėkaitis
  • 1,723
  • 19
  • 22
2

Daniel Saidi nailed it - https://danielsaidi.com/blog/2022/06/21/undimmed-presentation-detents-in-swiftui

He also put it as part of this package SwiftUIKit: https://github.com/danielsaidi/SwiftUIKit/commit/b256245928aadb5bf58f827e40d0b34d3267426f

cluelessCoder
  • 948
  • 6
  • 19