开发者

UIView rotation and movement

I try to rotate and move a UIImage. Here is my code :

im = [[UIImageView alloc ] initWithFrame:CGRectMake开发者_开发技巧(160, 240, 100, 100)];
im.image = [UIImage imageNamed:@"image.png"];
[view addSubview:im];
NSTimer * timer = [NSTimer scheduledTimerWithTimeInterval:1.0/30.0 target:self selector:@selector(actionIm) userInfo:nil repeats:YES];

-(void) actionIm
{
  [im setFrame:CGRectMake(im.frame.origin.x+1 , im.frame.origin.y+1 ,100, 100)];
  im.transform=CGAffineTransformMakeRotation (mRotation);
  mRotation+=0.1;
}

The result is a very strange behaviour : If I use only the rotation, it works. If I use only the move, it works. But both uses give a strange result (the IUImage "jump" bizzarly).

I red a lot of things about rotation, frame, bounds, center... but nothing that can solve my problem. Thank you.


Try moving the center instead of changing the frame. I believe setting the frame when the rotation is not Identity does something different.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜