你怎么能旋转Text,Button以及其他设计使用SwiftUI 90度controlls SwiftUI的?
我有意将我的问题建模为这个问题的 SwiftUI 版本:如何在 Swift 中为 UIButton 和 UILabel 旋转文本?
电流输出:
预期输出:
RPa*_*l99 10
使用任何一种.rotationEffect()方法View顺时针旋转,包括Button和Text。
例如,它绕Text其原点(其框架的中心)旋转:
Text("Turtle Rock")
.rotationEffect(Angle(degrees: 90)))
Run Code Online (Sandbox Code Playgroud)
使用带有锚点参数的重载方法围绕不同的点旋转。
例如,这围绕Text其框架的左下点旋转:
Text("Turtle Rock")
.rotationEffect(Angle(degrees: 90), anchor: .bottomLeading)
Run Code Online (Sandbox Code Playgroud)
您还可以使用弧度进行旋转:
Text("Turtle Rock")
.rotationEffect(radians: Double.pi / 2)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3675 次 |
| 最近记录: |