简体   繁体   中英

Rotating an image problem

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

只需将以下链接中的代码设置为: 在同一中心旋转图像

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM