如何使用 SwiftUI 将 SwiftUI 和其他设计控件旋转 90 度Text
?Button
我有意将我的问题建模为这个问题的 SwiftUI 版本:如何在 Swift 中旋转 UIButton 和 UILabel 的文本?
电流输出:
预期输出:
如何使用 SwiftUI 将 SwiftUI 和其他设计控件旋转 90 度Text
?Button
我有意将我的问题建模为这个问题的 SwiftUI 版本:如何在 Swift 中旋转 UIButton 和 UILabel 的文本?
电流输出:
预期输出:
使用任何一种.rotationEffect()
方法View
顺时针旋转,包括Button
和Text
。
例如,它围绕Text
其原点(其框架的中心)旋转:
Text("Turtle Rock")
.rotationEffect(Angle(degrees: 90)))
使用带有锚参数的重载方法围绕不同的点旋转。
例如,它围绕Text
其框架的左下角旋转:
Text("Turtle Rock")
.rotationEffect(Angle(degrees: 90), anchor: .bottomLeading)
您还可以使用弧度进行旋转:
Text("Turtle Rock")
.rotationEffect(radians: Double.pi / 2)