import SwiftUI
struct ContentView: View {
// 自定义颜色
let customColor = Color(red: 0.5, green: 0.7, blue: 0.9)
var body: some View {
VStack {
Text("Hello, SwiftUI!")
.foregroundColor(customColor) // 设置文本颜色为自定义颜色
.padding() // 使用默认的内边距
Text("Welcome to SwiftUI!")
.padding(20) // 设置内边距为20
.background(customColor) // 设置背景颜色为自定义颜色
.foregroundColor(.white) // 设置文本颜色为白色
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}