我有一个卡片视图,我给了它一些大小。我知道这是错误的。我想要可调整大小并按百分比分割,例如blue = 70%
和red = 30%
或类似的东西。但是不知道如何做。我是SwiftUI
上的新手。下面是我的代码:
let screen = UIScreen.main.bounds
struct CardView: View {
var body: some View {
VStack {
VStack {
Text("Blue")
}
.frame(width: screen.width - 60, height: 180)
.background(Color.blue)
VStack {
Text("Red")
}
.frame(width: screen.width - 60, height: 100)
.background(Color.red)
}
.frame(width: screen.width - 60, height: 280)
}
}
我的观点是: