【发布时间】:2021-06-24 15:56:36
【问题描述】:
所以我希望我的键盘覆盖视图,以便视图保持不变而不向上。我做了几个变体,比如将它添加到我的登录信息中,或者添加到它的导航视图中。它根本不起作用
这是我的代码
struct LoginView: View {
@StateObject var userData = UserData()
var body: some View {
NavigationView {
ZStack(alignment:.top) {
Color.pink.ignoresSafeArea(edges: .top)
VStack {
Image(systemName: "graduationcap.fill")
.resizable()
.scaledToFit()
.frame(width: /*@START_MENU_TOKEN@*/100/*@END_MENU_TOKEN@*/, height: /*@START_MENU_TOKEN@*/100/*@END_MENU_TOKEN@*/, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
.foregroundColor(.white)
.padding(.top,30)
Text("Study +")
.font(.title)
.fontWeight(.medium)
.foregroundColor(.white)
Spacer()
//Mark : The login Thinggy
LoginStuffs()
}
}
.edgesIgnoringSafeArea(.bottom)
.navigationTitle("Login")
.navigationBarHidden(true)
}
}
}
登录资料
struct LoginStuffs: View {
@State var username:String = ""
@State var password:String = ""
@State var isShow:Bool = false
var body: some View {
Vstack{
Textfield()
Securefield()
Securefield()
}
.padding()
.frame(width:UIScreen.width,height:UIScreen.height/1.5)
.background(Color.white)
.cornerRadius(15, corners: [.topLeft, .topRight])
//.ignoresSafeArea(edges: /*@START_MENU_TOKEN@*/.bottom/*@END_MENU_TOKEN@*/)
}
}
【问题讨论】:
-
我已经尝试将
.ignoresSafeArea(.keyboard)添加到视图中,但没有成功 -
添加
LoginStuffs() -
我做了,我尝试了变化,没有工作
-
我的意思是添加
LoginStuffs().. 的代码 :) -
好的。给你
标签: swiftui swiftui-navigationview