在 iCaorusel 中的每个视图上显示一系列图像
Display Series of Images on each View in iCaorusel
我有以下实现,它在轮播中的每个视图上显示每个单独的图像。以下代码有效且有效。
- (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];
}
UIImageView 有一个动画图像 属性。给它分配一个图像数组,它们应该会产生你想要的效果。
我有以下实现,它在轮播中的每个视图上显示每个单独的图像。以下代码有效且有效。
- (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];
}
UIImageView 有一个动画图像 属性。给它分配一个图像数组,它们应该会产生你想要的效果。