admin管理员组文章数量:1403229
I have a fullScreenCover, which then presents another sheet on top of it. I want this sheet to be translucent so I can apply materials over it. I had it working here:
struct ClearBackgroundView: UIViewRepresentable {
func makeUIView(context: Context) -> some UIView {
let view = UIView()
DispatchQueue.main.async {
view.superview?.superview?.backgroundColor = .clear
}
return view
}
func updateUIView(_ uiView: UIViewType, context: Context) {
}
}
struct ClearBackgroundViewModifier: ViewModifier {
func body(content: Content) -> some View {
content
.background(ClearBackgroundView())
}
}
extension View {
func clearModalBackground() -> some View {
self.modifier(ClearBackgroundViewModifier())
}
}
This is then called on a view like so:
StopDetail(coreStop: stop)
.clearModalBackground()
.background(
Color.background.opacity(0.7)
.ignoresSafeArea()
.background(.ultraThinMaterial))
This method works whenever the view isn't inside a fullScreenCover. If it's being presented from a fullScreenCover, this won't work, and the view will have a normal background as if my code doesn't do anything. From the hierarchy debugger, the view that's adding the background appears to be a PresentationHostingController (class UIHostingView).
How can I fix this?
本文标签: iosMake the background of a sheet presented in a fullScreenCover translucentStack Overflow
版权声明:本文标题:ios - Make the background of a sheet presented in a fullScreenCover translucent? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744379101a2603409.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论