【发布时间】:2020-08-03 20:59:00
【问题描述】:
我发现我可以像这样在swift中自定义TextField样式..
struct BottomLineTextFieldStyle: TextFieldStyle {
func _body(configuration: TextField<Self._Label>) -> some View {
VStack() {
configuration
Rectangle()
.frame(height: 1, alignment: .bottom)
.foregroundColor(Color.white)
}
}
}
这允许我使用“下划线形状样式”文本字段。
用法
TextField("placeholder", text: $value).textFieldStyle(BottomLineTextFieldStyle()).foregroundColor(.white)
但是我也想更改占位符颜色,但我不能。
那么,我的问题是如何自定义文本字段的占位符颜色? 请帮助我,感谢您的阅读。
【问题讨论】:
标签: ios swift swiftui textfield