У меня есть следующий вид, который я создаю с помощью SwiftUI:
var body: some View {
NavigationView {
VStack {
Spacer()
Group {
Text("Recipes")
.font(.title)
.padding(.bottom)
Text("The easiest way to save, search, and share recipes with family and friends.")
.font(.subheadline)
.foregroundColor(.gray)
.lineLimit(nil)
.multilineTextAlignment(.center)
.padding(.horizontal)
}
Spacer()
Group {
Divider()
CustomInput(text: $email, name: "Email")
.padding()
SecureField("Password", text: $password)
.modifier(InputModifier())
.padding([.leading, .trailing])
CustomButton(
label: "Sign In",
action: signIn,
loading: loading
)
.padding()
}
VStack {
Divider()
HStack(alignment: .center) {
Text("Don't have an account?")
.font(.footnote)
.foregroundColor(.gray)
NavigationLink(destination: SignUp()) {
Text("Sign Up.")
.font(.footnote)
}.simultaneousGesture(TapGesture().onEnded {
self.error = false
})
}
.padding()
}
}.offset(y: -self.value)
.animation(.spring())
.onAppear{
NotificationCenter.default.addObserver(forName: UIResponder.keyboardWillShowNotification, object: nil, queue: .main) { (noti) in
let value = noti.userInfo![UIResponder.keyboardFrameEndUserInfoKey] as! CGRect
let height = value.height
self.value = height
}
NotificationCenter.default.addObserver(forName: UIResponder.keyboardWillHideNotification, object: nil, queue: .main) { (noti) in
self.value = 0
}
}
}
}
То, что указано выше, предполагает, что он перемещает текстовые поля вверх, когда пользователь щелкает внутри любого из двух (2) текстовых полей либо по электронной почте, либо по паролю.
Мой вопрос: я бы хотел, чтобы первая группа, которая имеет имя приложения и краткое описание, полностью исчезла, а не сдвинулась вверх, поскольку в зависимости от размера устройства вы все равно можете увидеть вырезку краткого описания в верхней части устройства, например, с использованием iPhone 11 Pro Max.