2012-08-29 60 views
3

hy如果移动,UIImageView将缩放而不是旋转,iOS

我想制作一个小动画。如果图像是静态的,旋转工作正常。 但当我移动我的图像视图时,它会拉伸图像。如果图像没有旋转,则可以将图像移动至 。

-(void)play 
{ 

     CGRect ship=image.frame; 
     ship.origin.x=ship.origin.x+move; 
     ship.origin.y=ship.origin.y+move2; 
     image.frame=ship; 
} 

-(void)rotate 
{ 
     int degre=180; 
     float radian=degre*(3.14/180); 
     image.transform =CGAffineTransformMakeRotation(radian); 
} 
+0

这是您的实际代码? 'CGRect ship = image'看起来很可疑。 - 使用'M_PI'而不是'3.14'! –

回答

3

使用transform属性时,您不允许通过更改框架来更改位置,您必须使用center属性。

所以这应该有所帮助:

-(void)play 
{ 
    image.center=CGPointMake(image.center.x + move, image.center.y + move2); 
} 
+0

船没有一个可变的中心,如果我尝试在图像中,它不能直接操纵...写入快速 – WildWorld

+0

作品,但它将图像居中在屏幕中间,并保持在那里 – WildWorld

+0

现在就试试吧,请。它的工作原理是 –