I want to rotate a CGPoint on the screen depending on the angle and the rotation is anchored on another point. Was wondering what is the most efficient way of doing this?
Using Vladimir’s answer, below is the Swift 3 answer:
let initialPoint = CGPoint(x: 100, y: 100) // the point you want to rotate
let translateTransform = CGAffineTransform(translationX: initialPoint.x, y: initialPoint.y)
let rotationTransform = CGAffineTransform(rotationAngle: angle)
let customRotation = (rotationTransform.concatenating(translateTransform.inverted())).concatenating(translateTransform)
rotatedPoint = initialPoint.applying(customRotation)