ios - 在轮播中的每个 View 上显示一系列图像

标签 ios icarousel

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

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

但是,我想在每个 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];

}

最佳答案

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

关于ios - 在轮播中的每个 View 上显示一系列图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31123601/

相关文章:

ios - static UITableViewCell 如何防止 Contenttview 选择

ios - NSDate 问题

ios - AsyncDisplayKit错误(使用ASDK作为静态库)

ios - 创建数组并将元素分配给 UITableViewCell 并取回 labelText 元素时出现问题

iphone - 在 iCarousel 的 iCarouselTypeRotary View 中隐藏图像

ios - 超过iOS App的可执行文件大小

iphone - 使用 NStimer 设置默认图像的图像动画

iphone - 如何显示 iCarousel 中心 View 仅突出显示其他最近的 View 显示一些黑暗

ios - 如何调整 iCarouselTypeLinear View 移动到顶部的框架

ios - 在 iCarousel 上重用标识符