0

这是我的代码:

CABasicAnimation *animation = [CABasicAnimation 
                               animationWithKeyPath:@"transform.scale"];
[animation setFromValue:[NSNumber numberWithFloat:1.0f]];
[animation setToValue:[NSNumber numberWithFloat:3.0f]];
[animation setDuration:0.8];
[animation setRemovedOnCompletion:NO];
[animation setFillMode:kCAFillModeForwards];
[imageView.layer addAnimation:animation forKey:@"scale"];

[imageView setFrame:nowRect];

我发现这不对,因为当我将imageView框架设置为nowRect时,imageView的层又变大了!

4

1 回答 1

1

试试这个,你首先在 viewDidLoad 中设置你的图像大小......

例如:在本例中,a 和 b 是您最初需要的尺寸...

imageForAnimate.frame=CGRectMake(imageForAnimate.frame.origin.x, imageForAnimate.frame.origin.y, a, b); 

那么您需要将此代码附加到您需要的区域...

 [UIView animateWithDuration:0.8 animations:^{
        imageForAnimate.frame=CGRectMake(imageForAnimate.frame.origin.x, imageForAnimate.frame.origin.y, a*3, b*3);


    }]; 

我希望这能帮助你解决....

于 2012-09-04T03:16:10.593 回答