有没有办法使用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(),角度是弧度,而不是度数。
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
发布评论