One step affine transform for rotation around a point?

后端 未结 4 777
有刺的猬
有刺的猬 2020-11-27 03:13

How can I make a Core Graphics affine transform for rotation around a point x,y of angle a, using only a single call to CGAffineTransformMake() plus math.h trig functions su

4条回答
  •  醉梦人生
    2020-11-27 03:52

    for Swift 4

    print(x, y) // where x,y is the point to rotate around
    let degrees = 45.0
    let transform = CGAffineTransform(translationX: x, y: y)
        .rotated(by: degrees * .pi / 180)
        .translatedBy(x: -x, y: -y)
    

提交回复
热议问题