UIimageView围绕另一个UIImageView的中心点旋转

时间:2012-08-27 13:00:49

标签: iphone objective-c ios

我有两张照片。 一个图像是矩形 第二是三角形 我想用一根手指或触摸事件从矩形图像的中心点旋转图像。

http://i.stack.imgur.com/6zilY.png

2 个答案:

答案 0 :(得分:4)

好吧,如果你希望图像在矩形中心点周围以任意大小的圆圈旋转,那么数学会变得相当复杂,但一个好的开始是定义三角形图像视图的锚点,前

#import <QuartzCore/QuartzCore.h>
#define degreesToRadians(x) (M_PI * x / 180.0)


[[triangleImageView layer] setAnchorPoint:CGPointMake:(0.5,0.0)];
[UIView animateWithDuration:1.0 animations:^{
    [triangleImageView setTransform:CGAffineTransformMakeRotation(degreesToRadians(90))];
}];

答案 1 :(得分:0)

最后我发现我必须使用[view.layer setAnchorPoint:CGPointMake(0.5, 0.5)] 它解决了我的问题。

相关问题