【发布时间】:2020-03-07 19:30:38
【问题描述】:
为什么在我将 TextField 设置为使用定义的颜色后,它的背景仍然是白色?为什么还是白覆盖?
import SwiftUI
struct ContentView: View {
@State var search: String = ""
var body: some View {
ZStack{
Color.baseColour
.edgesIgnoringSafeArea(.all)
VStack(alignment: .center, spacing: 0) {
HStack(alignment: .center, spacing: 0) {
TextField("Search for a profile... ", text: $search)
.textFieldStyle(RoundedBorderTextFieldStyle())
.cornerRadius(15)
.background(Color.textFieldBarColour)
}
.frame(width: UIScreen.main.bounds.width - 30)
.background(Color.textFieldBarColour)}
【问题讨论】:
-
您必须在 StackOverflow 上发布代码而不是图像。查找这个答案,它说的一样,你可能需要使用 .overlay() stackoverflow.com/questions/58727341/…
标签: swiftui