struct ContentView: View {
var body: some View {
VStack {
Text("Hello World!")
.font(.largeTitle)
.fontWeight(.medium)
.foregroundColor(.white)
.padding(15)
.frame(alignment: .center)
.background(Color.red)
.cornerRadius(50)
Text("Hello World!")
.foregroundColor(.red)//设置文本颜色
// .font(.system(size: 30))//设置字体大小,指定字形
.font(.system(.largeTitle, design: .rounded))//largeTitle的样式而且是圆弧的
// .font(.custom("Courier", size: 30))//更改字体的字型
///设置字重--fontWeight 设置字重
Text("Hello, World!")
.foregroundColor(.red)
.font(.system(size: 30))
.fontWeight(.regular)
///设置阴影--shadow设置阴影
Text("Hello World!")
.foregroundColor(.red)
.font(.custom("Courier", size: 30))
.fontWeight(.regular)
.shadow(color: .black, radius: 2, x: 0, y: 15)
///设置文本对齐方式--multilineTextAlignment 指定文本的对齐方式
Text("Hello World! nice to miss you!")
.foregroundColor(.accentColor)
.font(.custom("Courier", size: 30))
.fontWeight(.regular)
.shadow(color: .black, radius: 2, x: 0, y: 1)
.multilineTextAlignment(.center)
.padding(EdgeInsets(top: 10, leading: 0, bottom: 0, trailing: 0))
///限制显示行数--lineLimit 将行数限制为一定数量
Text("Hello, World! welcome to OldBirds ,nice to miss you! see you again ~~Hello, World! welcome to OldBirds ,nice to miss you! see you again ~~ ")
.foregroundColor(.blue)
.font(.system(size: 30))
.fontWeight(.regular)
.lineLimit(3)
///设置行间距--lineSpacing 设置行间距
Text("Hello, World! welcome to OldBirds ,nice to miss you! see you again ~~ ")
.foregroundColor(.cyan)
.font(.system(size: 30))
.fontWeight(.regular)
.lineSpacing(10)
///旋轉文字
//2D 旋转
Text("Hello, World! welcome to OldBirds ,nice to miss you! see you again ~~ ")
.foregroundColor(.green)
.font(.system(size: 25))
.rotationEffect(.degrees(20), anchor:UnitPoint(x: 0, y: 0))
//3D 旋转
Text("Hello, World! welcome to OldBirds ,nice to miss you! see you again ~~ ")
.foregroundColor(.indigo)
.font(.system(size: 25))
.rotation3DEffect(.degrees(60), axis: (x: 1, y: 0, z: 0))
.padding(EdgeInsets(top: 10, leading: 0, bottom: 0, trailing: 0))
}
.padding()
}
}
如果本文对你有帮助,欢迎点赞、评论、关注…