我有一个简单的 TextField 并设置了高度和其他一些属性,但问题是文本字段高度没有改变,下面是我的代码
struct LoginView: View {
@State private var email = ""
@State private var password = ""
var body: some View {
VStack() {
TextField("Email", text: self.$email)
.frame(height: 55)
.textFieldStyle(RoundedBorderTextFieldStyle())
.cornerRadius(16)
.padding([.leading, .trailing], 24)
SecureField("Password", text: self.$password)
.frame(height: 55)
.textFieldStyle(RoundedBorderTextFieldStyle())
.cornerRadius(16)
.padding([.leading, .trailing], 24)
}
}
}
struct LoginView_Previews: PreviewProvider {
static var previews: some View {
LoginView()
}
}
Run Code Online (Sandbox Code Playgroud)
然而这行不通。
我想创建一个带有边框和背景颜色的圆角矩形视图的按钮。
到目前为止我写了这个:
Button(action: {
}, label: {
Text("TAP ME")
.foregroundColor(Color.blue)
})
.frame(height: 50)
.frame(maxWidth: .infinity)
.overlay(
RoundedRectangle(cornerRadius: 50, style: .continuous)
.strokeBorder(Color.blue, lineWidth: 1)
)
Run Code Online (Sandbox Code Playgroud)
我试图.background(Color.red)在许多不同的地方添加,但这是我每次得到的:
在这里做什么?
感谢您的帮助