【问题标题】:Display Series of Images on each View in iCaorusel在 iCaorusel 中的每个视图上显示一系列图像
【发布时间】:2015-06-29 19:08:06
【问题描述】:

我有以下实现,它在轮播中的每个视图上显示每个图像。以下代码工作正常。

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view{

    if (view == nil){
        view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200 , 200)];
        ((UIImageView *)view).image = [self.items objectAtIndex:index];
        view.contentMode = UIViewContentModeCenter;
        [view.layer setMasksToBounds:YES];
    }
    return view;
}

但是,我想在每个视图上显示一系列图像(动画)。那可能吗?我有三种观点——步行、骑自行车和开车。这是我的动画系列图像实现之一。但是,我无法找到适合 iCarousel 的方法。

-(void)walkingAnimation
{
    NSInteger imagesCount = 22;
    NSMutableArray *images = [[NSMutableArray alloc] init];
    //iterate through each images
    for (int i = 0;
         i <= imagesCount; i++) {
        [images addObject:[UIImage imageNamed:[NSString stringWithFormat:@"Walking-%d", i]]];
    }

    avatarImage.animationImages = images;
    avatarImage.animationDuration = 1.5;
    [self.view addSubview:avatarImage];
    [avatarImage startAnimating];

}

【问题讨论】:

    标签: ios icarousel


    【解决方案1】:

    UIImageView 有一个 animatedImage 属性。为其分配一组图像,它们应该会产生您想要的效果。

    【讨论】:

      猜你喜欢
      • 2015-12-14
      • 2018-07-27
      • 1970-01-01
      • 2012-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-22
      • 2016-04-11
      相关资源
      最近更新 更多