WildWorld
WildWorld

Reputation: 517

UIImageView will scale instead of rotation if moved , iOS

hy

i want to make a little animation.the rotation works fine if the image is static. but when i move my image view it will stretch the image. the image can be moved whit out a problem if it's not rotated.

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

Upvotes: 3

Views: 260

Answers (1)

Marián Černý
Marián Černý

Reputation: 15738

When using the transform property you are not allowed to change the position by changing the frame, you have to use the center property.

So this should help:

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

Upvotes: 3

Related Questions