【发布时间】: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];
}
【问题讨论】: