旋转图像问题

发布于 2024-11-06 08:00:03 字数 578 浏览 1 评论 0原文

我试图通过触摸和移动来旋转图像。

这是我用于旋转视图的代码

[myView.layer setAnchorPoint:CGPointMake(1.0, 1.0)];

CODE INSIDE touchMoved

CGPoint Location = [[touches anyObject] locationInView:self.view];

Float32 Angle = (atan2(Location.x - myView.layer.center.x, Location.y - myView.layer.center.y));

myView.layer.transform = CGAffineTransformMakeRotation(-Angle);

现在一切都工作正常,除了一个

如果我从视图中间旋转,那么一切工作正常,但是当我尝试从角落旋转它时,它会跳跃并将我的触摸点作为中心(记住我已将视图的右下角固定,请参阅锚点)。我只需将视图旋转到 90 度,但只能使用单指触摸...我不确定我是否能够正确描述我的问题,但问题

I'm trying to rotate an image by just touch and move.

Here is my code for rotating the view

[myView.layer setAnchorPoint:CGPointMake(1.0, 1.0)];

CODE INSIDE touchMoved

CGPoint Location = [[touches anyObject] locationInView:self.view];

Float32 Angle = (atan2(Location.x - myView.layer.center.x, Location.y - myView.layer.center.y));

myView.layer.transform = CGAffineTransformMakeRotation(-Angle);

Now everything works fine except one

If I rotate from the middle of the view then all work fine but when I try to rotate it from corners the it jumps and make my touch point as center (remember i have made lower right side corner of the view fixed, see the anchor point). I just have to rotate the view up to 90 degree but only using single finger touch... I'm not sure if I was able to describe my problem correctly but problem

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最偏执的依靠 2024-11-13 08:00:03

只需将以下链接中的代码放入即可:在同一中心旋转图像

just put the code from the following link as it :Rotate the image on the same center

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文