如何在一点旋转CALayer [英] how to rotate CALayer at one point

查看:75
本文介绍了如何在一点旋转CALayer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在一个选定点旋转CALayer。

how to rotate CALayer at one selected point.

推荐答案

CATransform3D transform = CATransform3DIdentity;
transform = CATransform3DTranslate(transform, rotationPoint.x-center.x, rotationPoint.y-center.y, 0.0);
transform = CATransform3DRotate(transform, rotationAngle, 0.0, 0.0, -1.0);
transform = CATransform3DTranslate(transform, center.x-rotationPoint.x, center.y-rotationPoint.y, 0.0);

其中中心是图层的中心, rotationAngle 以弧度为单位(正为逆时针方向), rotationPoint 是您想要旋转的点。 center rotationPoint 位于包含视图的坐标空间中。

Where center is the center of your layer, rotationAngle is in radians (positive is counterclockwise), and rotationPoint is the point about which you wish to rotate. center and rotationPoint are in the coordinate space of the containing view.

这篇关于如何在一点旋转CALayer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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