旋转图像问题
我试图通过触摸和移动来旋转图像。
这是我用于旋转视图的代码
[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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将以下链接中的代码放入即可:在同一中心旋转图像
just put the code from the following link as it :Rotate the image on the same center