2011-01-31 85 views
1

我想使用CGAffineTransformScale制作UIImageView的动画,并伴随着动画,uiimageview也应该改变它的原点。让我写下面的方法,UIImageView动画问题?

- (无效)imageDidMoving {

imageV = [[UIImageView alloc] init]; 
imageV.frame = CGRectMake(0, 0, 768, 1024); 
imageV.contentMode = UIViewContentModeScaleToFill; 
[self.view addSubview:imageV]; 
imageV.image = [UIImage imageNamed:@"image.png"]; 
imageV.autoresizingMask = UIViewAutoresizingFlexibleWidth || UIViewAutoresizingFlexibleHeight; 

imageV.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.1, 0.1); 
[UIView beginAnimations:@"image animation" context:nil]; 
[UIView setAnimationDuration: 0.75];  
imageV.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.0, 1.0); 
[UIView commitAnimations]; 

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:.3]; 
imageV.transform = CGAffineTransformScale(CGAffineTransformIdentity,1.5, 1.5); 
[UIView commitAnimations]; 

}

,但它并没有奏效。 我也使用CGAffineTransformScale代替,

CGRect frame2 = CGRectMake(70,70, 300, 600);    
    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDuration:1.0]; 
    imageView.frame = frame2; 
    [UIView commitAnimations]; 

,但它也不能正常工作?

如何在不使用NSTimer的情况下缩放和更改UIImageView的原点?

回答

-1
imageV.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.1, 0.1); 
[UIView beginAnimations:@"image animation" context:nil]; 
[UIView setAnimationDuration: 0.75];  
imageV.center = CGPointMake(65, 270); 
imageV.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.76, 1.24); 
[UIView commitAnimations];  
+0

硬编码永远不是解决方案 – 2013-01-16 15:55:04