问题描述
有没有办法使用CGAffineTranformMAkeRotation围绕外部点旋转UIImage?
tnx很多!
这是一个使用与CoreGraphics CGAffineTransform API格式相同格式的函数。 / p>
这完全适用于其他RotateAt()API应该如何工作。
该操作代表相当于以下规范:translate(pt.x,pt.y);旋转(角度); translate(-pt.x,-pt.y);
CGAffineTransform CGAffineTransformMakeRotationAt(CGFloat angle,CGPoint pt){
const CGFloat fx = pt.x,fy = pt.y,fcos = cos(角度),fsin = sin(角度);
返回CGAffineTransformMake(fcos,fsin,-fsin,fcos,fx - fx * fcos + fy * fsin,fy - fx * fsin - fy * fcos);
}
就像 CGAffineTransformMakeRotation()$ c一样$ c>,角度是弧度,而不是度数。
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.
这篇关于围绕外部点的CGAffineTransformMakeRotation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!