objective-c - 如何在UIImageView中更改图像时实现动画

标签 objective-c animation uiimageview uiimage

我有一个 NSArray *pictureRefs,其中包含图片名称。

这些图片要显示在UIImageView中_mainImage 到目前为止效果很好。
目前我正在使用左侧和右侧的按钮来执行此操作,请参见下图。这些按钮具有与pictureRefs相对应的标签。

更改非常直接地发生,没有任何影响。
我想实现像动画一样的封面流。

有什么想法可以实现这一目标吗?

我的切换图像的代码

string =  [pictureRefs objectAtIndex:tag];
UIImage  *image  = [UIImage imageNamed:string];
[_mainImage setImage:image]; //Here I would like to make animations

enter image description here

最佳答案

单击任何按钮时调用此方法

-(void)check_changeImage:(NSInteger)Value
{
    NSString *strimagename=[NSString stringWithFormat:@"dice_0%d.png",Value];//fetch image here as per you want 

 [UIView animateWithDuration:1.0 
                 animations:^{
                     imgviewDice1.image.alpha = 1.0;
                 }
                 completion:^(BOOL finished){

                     imgviewDice1.image=[UIImage imageNamed:strimagename];

                     // do something after the animation finished, 
                     // maybe releasing imageA if it's not used anymore...
                 }];

}

也许会有帮助。

关于objective-c - 如何在UIImageView中更改图像时实现动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19334214/

相关文章:

ios - 来自 UIImage 的 NSData。以错误的方向上传到服务器

ios - 在 iOS 中是否有向后滑动手势的回调?

html - 使用css3的页面分割动画

delphi - 在 FireMonkey 中动画添加字符串到列表框

ios - 设置UIButton图像的内容模式

ios - 在 UIImageView 上打字

ios - 解析 : Create 1-to-1 relation on PFObject with support for multiple class types?

c++ - 沿 cocos2dx 中的路径移动动画 Sprite

ios - UIImageView 是否有任何 UV 坐标(或类似坐标)?

ios - 检测音量按钮按下和释放 iOS