Код: Выделить всё
struct ContentView: View {
u/State var name: String = ""
@State var address: String = ""
var body: some View {
VStack {
TextField("Name", text: $name)
.textFieldStyle(OutlinedTextFieldStyle())
TextField("Address", text: $address)
}
.padding(200.0)
.background(.white)
.preferredColorScheme(.light)
}
}
struct OutlinedTextFieldStyle: TextFieldStyle {
@FocusState var isFocused: Bool
func _body(configuration: TextField) -> some View {
configuration
.focused($isFocused)
.background(.clear)
.overlay {
RoundedRectangle(cornerRadius: 8, style: .continuous)
.stroke(.gray, lineWidth: isFocused ? 4 : 2)
}
}
}
[img]https://i. sstatic.net/XKxC1Ncg.png[/img]
Как вы можете видеть, когда я фокусируюсь на текстовом поле по умолчанию, TextField расширяется и появляется тень. Я хочу удалить этот эффект и добавить дополнительные настройки, когда TextField находится в фокусе. Как мне этого добиться?
Подробнее здесь: https://stackoverflow.com/questions/793 ... in-swiftui
Мобильная версия