are there a way for rotate UIImage around external point using CGAffineTranformMAkeRotation? tnx a lot!
Here is a function that uses the same format as the CoreGraphics CGAffineTransform API format.
This works exactly how other "RotateAt()" APIs should work.
The operation represents the equivalent of the following specification: translate(pt.x, pt.y); rotate(angle); translate(-pt.x, -pt.y);
CGAffineTransform CGAffineTransformMakeRotationAt(CGFloat angle, CGPoint pt){
const CGFloat fx = pt.x, fy = pt.y, fcos = cos(angle), fsin = sin(angle);
return CGAffineTransformMake(fcos, fsin, -fsin, fcos, fx - fx * fcos + fy * fsin, fy - fx * fsin - fy * fcos);
}
Just like with CGAffineTransformMakeRotation()
, angle is in radians, not degrees.
Set the image view's layer's anchorPoint to something outside of (0,0) and (1,1), ie view.layer.anchorPoint = CGPointMake(2, 2).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With