Text/文本, Shapes/形状, Colors/颜色 的使用

1. Text 的使用

// 多行文本
// Hello, World! This is the Swiftful Thinking Bootcamp. I am really enjoying this course and learning alot.

// .lowercased() 文字小写 .uppercased() 文字大写 capitalized: 以单词形式显示
Text("Hello, World!".capitalized)
//.font(.body) //字体大小
//.fontWeight(.semibold) // 权重
//.bold()  // 加粗
//.underline()
//.underline(true, color: Color.red) // 下划线
//.italic() // 倾斜
//.strikethrough(true, color: Color.green) // 删除线
//.font(.system(size: 24, weight: .semibold, design: .serif))// 字体样式
//.baselineOffset(10.0) // 行间隔
//.kerning(10)   // 文字间隔
//.multilineTextAlignment(.leading)// 多行对齐方式
    .foregroundColor(.red) // 颜色
    .frame(width: 200, height: 100, alignment: .center) // 位置
    .minimumScaleFactor(0.1) // 缩小适配 frame 区域

2. Shapes 的使用

// Circle()  // 圆
// Ellipse() // 椭圆
// Rectangle()   // 矩形
RoundedRectangle(cornerRadius:10) // 圆角矩形
// Capsule(style: .circular) // 胶囊
//.fill(Color.green)      // 填充颜色
//.foregroundColor(.pink) // 设置颜色
//.stroke()               // 描边
//.stroke(Color.red)      // 描边颜色
//.stroke(Color.blue, lineWidth: 2.0) // 描边颜色和线宽
//.stroke(Color.orange, style: StrokeStyle(lineWidth: 30, lineCap: .round,  dash: [30])) // 描边颜色和样式
//.trim(from: 0.4, to: 1.0)// 裁剪/修剪
//.stroke(Color.purple, lineWidth: 50) // 描边颜色和线宽
    .frame(width: 300, height: 200) // 宽高

3. Colors 的使用

  3.1 实现

RoundedRectangle(cornerRadius: 25.0) // 圆角矩形
    .fill(
        // Color.primary
        // Color(UIColor.secondarySystemBackground)
        Color("CustomColor")
    ) // 填充颜色
    .frame(width: 300, height: 200) // 设置宽高
//.shadow(radius: 10) // 周围阴影
    .shadow(color: Color("CustomColor").opacity(0.3), radius: 10, x: -20, y: -20) // 自定义阴影

  3.2 自定义颜色 CustomColor,如图:

  3.3 效果图: 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Hanyang Li

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值