0

Can me explane how I can rotate image use anchor point like

https://www.dropbox.com/s/vh3h5cr1mkdbfh3/ex_image2.JPG

on .m

#import <QuartzCore/QuartzCore.h>

on .h

[UIView animateWithDuration:0.7f
                          delay:0
                        options:UIViewAnimationOptionCurveEaseOut
                     animations:^
     {
         self.center = position;
         self.layer.anchorPoint = CGPointMake(-1, 0);
         self.transform = CGAffineTransformMakeRotation(-5);

     }
                     completion:^(BOOL completed){

                     }];

When I use this code I have something like that

https://www.dropbox.com/s/v87abux9dqm4y0p/ex_image1.JPG

4

1 回答 1

0

当您对图层应用旋转变换时,旋转会围绕锚点进行。

所以先将图层的锚点设置为(0.0, 0.0)。

self.layer.anchorPoint = CGPointMake(0.0f, 0.0f);

然后您可以旋转视图,旋转将围绕锚点 (0.0, 0.0) 进行。

[UIView animateWithDuration:2.0f animations:^{
    self.transform = CGAffineTransformMakeRotation(3.1415f);
}];

代码将以您所描绘的方式将视图旋转一整圈。

您可以查看Apple 的“Core Animation Programming Guide”中标题为“Anchor Points Affect Geometric Manipulations”的部分以获取更多信息。

于 2013-02-19T21:04:50.807 回答