2012-09-03 27 views
0

这是我的代码:当我调整一层imageview的图层时,我可以同时调整uiimageview的大小吗?

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的层更大的再次​​变得!有人能帮助我吗?非常感谢!!!

+0

你好,你的实际需要是什么...... – Spynet

+0

嗨,我很抱歉,我的英语很糟糕。我想让imageview的框架成为imageview图层在动画之后显示的框架。 –

+0

什么是你之前和之后的框架大小.... – Spynet

回答

1

试试这款U首先设置在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); 


    }]; 

我希望这将帮助您解决....

+0

注意:上面的代码工作更大,只有iOS 4.0版本... – Spynet

+0

感谢您!我只想知道何时使用图层动画,如何使视图的框架移动到视图图层所在的框架中,但您答案所说的动画就是我想要的。 –

+0

@Abel_CN您随时欢迎并继续发布问题 – Spynet

相关问题