【问题标题】:Animate iphone tableviewCell background image with two images使用两个图像为 iphone tableviewCell 背景图像设置动画
【发布时间】:2012-06-26 16:02:51
【问题描述】:

我想用 didSelectRowAtIndexPath 上的两个闪烁图像为 tableviewcell 背景图像设置动画。我们可以使用以下代码,但它会在背景中显示一张图像。但是我想要像闪烁的图像一样的gif。

cell.backgroundView = [ [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"correctAnswer.png"]]autorelease];  

【问题讨论】:

    标签: iphone uitableview didselectrowatindexpath


    【解决方案1】:

    UIImageView 可以使用animationImages 属性来制作动画。

    UIImageView* imgView = [[[UIImageView alloc] init] autorelease];
    imgView.animationImages = [NSArray arrayWithObjects:
        [UIImage imageNamed:@"correctAnswer1.png"],
        [UIImage imageNamed:@"correctAnswer2.png"], nil];
    
    imgView.animationDuration = 0.5;
    cell.backgroundView = imgView;
    [imgView startAnimating];
    

    您需要将动画的每一帧都包含在您的项目中,correctAnswer1.png、correctAnswer2.png 等...

    另外,使用UITableViewCell 的imageView 属性不是更好吗?这样,您的动画就会出现在单元格的左侧,并且不会干扰文本或单元格的任何其他部分...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-06
      • 2020-12-29
      • 1970-01-01
      相关资源
      最近更新 更多