You can rotate a view by creating a Transform
and setting it to the view’s property:
view.transform = Transform.makeRotation()
Rotating a Transform will adjust itself between
-M_PI
andM_PI
, if you need to accumulate or set rotations higher than+/- PI
you can use the.rotation
property.
let r = Rectangle(frame: Rect(0, 0, 200, 200))
r.lineWidth = 15.0
r.center = canvas.center
let rotate = Transform.makeRotation(M_PI_4)
r.transform = rotate
canvas.add(r)