Код: Выделить всё
Device: iPhone XR
iOS: 18.3.2
Need to support: iOS 15.0+
< /code>
Я тестирую доступность с внешней клавиатурой Bluetooth. Я включил полный доступ к клавиатуре
Код: Выделить всё
struct ContentView: View {
@State private var count = 0
@State var text1 = ""
@State var text2 = ""
@FocusState private var focusedButton: Int?
var body: some View {
VStack {
VStack(spacing: 24.0) {
Text("Btn Tap Count: \(count)")
TextField("text field 1", text: $text1)
.textFieldStyle(RoundedBorderTextFieldStyle())
.focused($focusedButton, equals: 1)
TextField("text field 2", text: $text2)
.textFieldStyle(RoundedBorderTextFieldStyle())
.focused($focusedButton, equals: 2)
Button(action: {
count += 1
}, label: {
Text("BTN TO Increase")
.padding(.vertical, 8.0)
.frame(maxWidth: .infinity)
})
.background(Color.green)
.cornerRadius(10)
Button(action: {
count -= 1
}, label: {
Text("BTN TO Decrease")
.padding(.vertical, 8.0)
.frame(maxWidth: .infinity)
})
.background(Color.orange)
.cornerRadius(10)
}
.padding(.top, 24)
.padding()
}
}
}
Код: Выделить всё
struct ContentView: View {
@State private var count = 0
@State var text1 = ""
@State var text2 = ""
@FocusState private var focusedButton: Int?
var body: some View {
ScrollView { // only change is here from previous example
VStack(spacing: 24.0) {
Text("Btn Tap Count: \(count)")
TextField("text field 1", text: $text1)
.textFieldStyle(RoundedBorderTextFieldStyle())
.focused($focusedButton, equals: 1)
TextField("text field 2", text: $text2)
.textFieldStyle(RoundedBorderTextFieldStyle())
.focused($focusedButton, equals: 2)
Button(action: {
count += 1
}, label: {
Text("BTN TO Increase")
.padding(.vertical, 8.0)
.frame(maxWidth: .infinity)
})
.background(Color.green)
.cornerRadius(10)
Button(action: {
count -= 1
}, label: {
Text("BTN TO Decrease")
.padding(.vertical, 8.0)
.frame(maxWidth: .infinity)
})
.background(Color.orange)
.cornerRadius(10)
}
.padding(.top, 24)
.padding()
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... -from-text