iphone - CGAffineTransformMakeRotation 围绕外部点

标签 iphone ios core-graphics

有没有办法使用 CGAffineTranformMAkeRotation 围绕外部点旋转 UIImage? 非常感谢!

最佳答案

这是一个使用与 CoreGraphics CGAffineTransform API 格式相同格式的函数。

这与其他“RotateAt()”API 的工作方式完全相同。

该操作相当于以下规范:translate(pt.x, pt.y);旋转(角度);翻译(-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);
}

就像 CGAffineTransformMakeRotation() 一样,角度以弧度为单位,而不是度数。

关于iphone - CGAffineTransformMakeRotation 围绕外部点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7232460/

相关文章:

iphone - 是否可以在不损失质量的情况下调整 UIImage 的大小?

ios 辅助功能焦点被困在状态栏上

ios - 以编程方式创建 ViewController 时,如何将其 View 设置为 SKVIew 类型?

iOS swift : Getting repeated value while updating 2D Array in custom UITableView cell

ios - UIBezierPath 和 NSBezierPath 在绘制圆弧时产生不同的结果

ios - 如何在CoreGraphics中为CGContextFillEllipseInRect添加偏移量?

iphone - 当应用程序为 applicationDidEnterBackground 时,GData YouTube 在后台上传

iphone - 苹果的大图标(512x512)应用商店指南是什么

iphone - InAppPurchase 无效的产品标识符 - 可能的原因

ios - swift 3.0 错误 "Cannot convert value of type"