我正在尝试以小尺寸呈现模型视图。有什么办法可以调整大小吗。
Button("Present") { self.presentingModal = true }
.padding()
.sheet(isPresented: $presentingModal) {}
content: {
ModelView(presentedAsModal: $presentingModal)
}
它以默认尺寸显示模型。我无法调整它的大小。
PS:我们的目标是在中心呈现定制尺寸的莫代尔。
您可以将调整大小的覆盖在当前的上View
轻按一下按钮。
import SwiftUI
struct SheetView: View {
@State private var showSheet: Bool = false
var body: some View {
NavigationView {
VStack {
ZStack {
Button("Please select a mailing address") {
showSheet.toggle()
}.foregroundColor(Color.black)
}
Spacer()
}
.navigationBarTitleDisplayMode(.inline)
.navigationViewStyle(StackNavigationViewStyle())
//.ignoresSafeArea()
}
.overlay(popOver)
}
var popOver: some View {
Group {
if showSheet {
ZStack(alignment: .bottom) {
Color.black.opacity(0.4).ignoresSafeArea()
.onTapGesture {
showSheet.toggle()
}
ZStack {
Rectangle()
.fill(Color.white)
.frame(maxWidth: .infinity, maxHeight: 340.0)
.cornerRadius(20.0, corners: [.topLeft, .topRight])
HelloView()
}
}
}
}
}
}
struct HelloView: View {
var body: some View {
Text("Hello")
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)