【问题标题】:How to achieve animations when changing image in UIImageViewUIImageView中改变图片时如何实现动画
【发布时间】:2013-10-12 12:32:01
【问题描述】:

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

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

变化非常直接,没有任何影响。
我想实现像动画一样的coverflow。

有什么想法可以实现吗?

我的图片切换代码

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

【问题讨论】:

标签: objective-c animation uiimageview uiimage


【解决方案1】:

点击任意按钮时调用该方法

-(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...
                 }];

}

也许会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多