UIImageView在移动时会进行缩放而不是旋转,iOS。

3

您好

我想制作一些小动画。如果图像是静态的,则旋转功能正常。但是当我移动我的图像视图时,它会拉伸图像。如果不旋转,该图像可以轻松移动而不会出现问题。

-(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); 
}

这是你实际的代码吗?CGRect ship=image 看起来有点可疑。- 使用 M_PI 代替 3.14 - Martin R
1个回答

3
使用 transform 属性时,不能通过更改帧来更改位置,必须使用 center 属性。因此,应该这样做:
-(void)play
{
    image.center=CGPointMake(image.center.x + move, image.center.y + move2);
}

船没有一个变量中心,如果我尝试在图像中操作它,它不能直接被操纵...写得太快了。 - WildWorld
可以正常工作,但它会将图像居中显示在屏幕中央并保持不动。 - WildWorld
你打断了我两天的研究,让我明白为什么我的旋转物品不能移动,谢谢!!! - Laurent Crivello

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接