使用.fullScreenCover()
ViewModifier并设置其背景时,在方向更改动画期间不会考虑该背景。
如何在更改方向时消除白色背景?
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Spacer()
HStack {
Spacer()
}
}
.fullScreenCover(isPresented: .constant(true)) {
VStack {
Spacer()
HStack {
Spacer()
}
}
.background(Color.black.ignoresSafeArea())
}
.background(Color.red.ignoresSafeArea())
}
}
在此特定情况下,在调整视图大小期间(在单独的窗口中打开gif),它(部分)显示白色背景:
1条答案
按热度按时间yx2lnoni1#
多亏了this answer,才找到了解决方案。
您需要获取底层的UIKit视图并将其背景色更改为
.clear
(默认情况下似乎是.white
,如果苹果可以更改它,那就太好了):然后将其应用于SwiftUI视图: