0

我有一个 UIImageView,这个: 在此处输入图像描述

我想做一个动画,从左边慢慢显示这个图像视图。然后我在xib中用“左”模式裁剪这个图像视图,我想用这个代码放大它。我在 3 点裁剪宽度,它以尺寸 (3,28) 开始,它应该以尺寸 (620,28) 结束

我使用这段代码来做到这一点:

[UIView beginAnimations:@"moveprogress" context:nil];
    [UIView setAnimationDuration:7.0];
    [UIView setAnimationDelegate:self];
    [progressBar setFrame:CGRectMake(progressBar.frame.origin.x, progressBar.frame.origin.y, 620, progressBar.frame.size.height)];
    [UIView commitAnimations];

但是动画不起作用,它会立即以全尺寸显示图像视图。为什么?

4

1 回答 1

0
//initial frame
CGRect initalImageFrame = [imageView frame];
initalImageFrame.size.width = 3.0f;
[imageView setFrame:initalImageFrame];


//animation

CGRect fullImageFrame = [imageView frame];
fullImageFrame.size.width = 640.0f;
[UIView animateWithDuration:7.0f animations:^{
    [imageView setFrame:fullImageFrame];
}];
于 2013-11-19T14:27:09.233 回答