I have the following implementation.
However, I only want the displayed(active) view animation works, other view animation are disabled unless until user scrolls it. In my current solution, all view animation works at the same time, I need to find a way to stop other view animations.
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view{
if (view == nil){
if(index==0)
{
view=[[UIImageView alloc]initWithFrame:CGRectMake(30, 30, 600, 600)];
((UIImageView *)view).animationImages=[NSArray arrayWithObjects:[UIImage imageNamed:@"Walking-1.png"],
[UIImage imageNamed:@"Walking-2.png"],
[UIImage imageNamed:@"Walking-3.png"],
[UIImage imageNamed:@"Walking-4.png"],
[UIImage imageNamed:@"Walking-5.png"],nil];
((UIImageView *)view).animationDuration = 1.5;
[((UIImageView *)view) startAnimating];
}
else if(index==1)
{
view=[[UIImageView alloc]initWithFrame:CGRectMake(30, 30, 600, 600)];
((UIImageView *)view).animationImages=[NSArray arrayWithObjects:[UIImage imageNamed:@"Biking-1.png"],
[UIImage imageNamed:@"Biking-2.png"],
[UIImage imageNamed:@"Biking-3.png"],
[UIImage imageNamed:@"Biking-4.png"],
[UIImage imageNamed:@"Biking-5.png"],nil];
((UIImageView *)view).animationDuration = 1.5;
[((UIImageView *)view) startAnimating];
}
view.contentMode = UIViewContentModeCenter;
[view.layer setMasksToBounds:YES];
}
return view;
}
Aucun commentaire:
Enregistrer un commentaire