我有以下实现,它在轮播中的每个 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/