围绕外部点的CGAffineTransformMakeRotation [英] CGAffineTransformMakeRotation around external point

查看:101
本文介绍了围绕外部点的CGAffineTransformMakeRotation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆