工具版本:
xcode: 12.5.1
swift: 5.4.2
实例代码:
struct HomeView: View {
var body: some View {
// 堆叠布局, 其他布局同样的设置方式
ZStack{
// 布局内容
Text("hello World")
}
// 使布局撑满屏幕
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
// 设置背景色
.background(Color.blue)
}
}
效果图: