文章目录
SwiftUI学习笔记之菜鸡进击第一天
Spacer控件
Spacer
是一个占位符控件,在VStack
和HStack
中会自动占满剩余的空间.
resizable属性
Image
默认不能修改图片大小的,如果需要修改大小,则需要使用resizable
方法
Image("Logo").resizable() .frame(width: 30.0, height: 30.0)
foregroundColor属性
foregroundColor
设置 Text
的文字颜色,之前的为color
,已修改为foregroundColor
bold属性
设置文字粗体的属性
font属性
设置文字样式的属性,比如title,headline,targetTitle等
cornerRadius属性
设置控件的圆角属性
shadow属性
设置控件的阴影值
属性顺序
在使用控件的属性时,需要注意属性的顺序,顺序不对,属性无法设置成功.
比如这样,先设置颜色,在设置大小,则大小设置失败.
VStack {
Text("Blue Card")
}
.background(Color.blue)
.cornerRadius(10)
.frame(width:<