Код: Выделить всё
struct Settings: View {
@State private var input1: String = ""
@State private var input2: String = ""
@State private var input3: String = ""
@State private var input4: String = ""
@State private var input5: String = ""
init() {
let coloredAppearance = UINavigationBarAppearance()
coloredAppearance.configureWithTransparentBackground()
coloredAppearance.backgroundColor = .gray
UINavigationBar.appearance().standardAppearance = coloredAppearance
UINavigationBar.appearance().compactAppearance = coloredAppearance
UINavigationBar.appearance().scrollEdgeAppearance = coloredAppearance
}
var body: some View {
NavigationView {
VStack(spacing: 16) {
Group {
VStack {
Text("Input 1")
.frame(maxWidth: .infinity, alignment: .leading)
TextField("", text: $input1)
.disableAutocorrection(true)
.padding()
.overlay(RoundedRectangle(cornerRadius: 5).stroke(.gray))
}
}
Group {
VStack {
Text("Input 2")
.frame(maxWidth: .infinity, alignment: .leading)
TextField("", text: $input2)
.disableAutocorrection(true)
.padding()
.overlay(RoundedRectangle(cornerRadius: 5).stroke(.gray))
}
}
Group {
VStack {
Text("Input 3")
.frame(maxWidth: .infinity, alignment: .leading)
TextField("", text: $input3)
.disableAutocorrection(true)
.padding()
.overlay(RoundedRectangle(cornerRadius: 5).stroke(.gray))
}
}
Group {
VStack {
Text("Input 4")
.frame(maxWidth: .infinity, alignment: .leading)
TextField("", text: $input4)
.disableAutocorrection(true)
.padding()
.overlay(RoundedRectangle(cornerRadius: 5).stroke(.gray))
}
}
Spacer()
}
.navigationBarTitle("Header", displayMode: .inline)
}
.ignoresSafeArea()
}
}
С клавиатурой
Есть ли у кого-нибудь способ предотвратить это? Пробовал проставки безуспешно. Хотя это может сохранить текст видимым, между панелью навигации и текстом создается пространство, когда клавиатура не открыта. я тоже пробовал возиться
Код: Выделить всё
ignoresSafeArea(.keyboard)В идеале, если выбрано верхнее текстовое поле, клавиатура должна закрывать нижние текстовые поля, не поднимая ничего вверх. Я хотел бы поднимать контент только в случае необходимости, чтобы сохранить видимым выбранное в данный момент текстовое поле. У кого-нибудь есть способ сделать это? Заранее спасибо.
Подробнее здесь: https://stackoverflow.com/questions/700 ... gation-bar
Мобильная версия