【发布时间】:2019-10-16 11:47:57
【问题描述】:
我们如何在SwiftUI 中实现Button 的proportional 大小
struct ContentView: View {
@State private var emailText = ""
@State private var passwordText = ""
var body: some View {
NavigationView {
ScrollView {
VStack(alignment: .center, spacing: 30.0, content: {
TextField("Enter Email", text: $emailText)
.textFieldStyle(RoundedBorderTextFieldStyle())
SecureField("Enter Password", text: $passwordText)
.textFieldStyle(RoundedBorderTextFieldStyle())
Button(action: {
print("Button Tapped")
}) {
Text("Login")
}.frame(width: 100,
height: 40,
alignment: .center).background(Color.orange)
Button(action: {
print("Button Tapped")
}) {
Text("Sign Up")
}.frame(width: 150,
height: 40,
alignment: .center).background(Color.yellow)
}).padding()
}
.navigationBarTitle("Login")
}
}
}
如何根据设备实现登录和注册按钮的比例。
【问题讨论】: