Reputation: 1
Have the below animation running.Trying to send [upwardView.layer removeAllAnimations];
With IBAction
button
. If anyone could shed some light for yet another noob.
UIView* upwardView=[[UIView alloc]init];
[upwardView setFrame:CGRectMake(10, 175, 86, 140)];
[self.view addSubview:upwardView];
[self.stageView addSubview:upwardView];
NSArray *animationImages=[NSArray arrayWithObjects:
[UIImage imageNamed:@"win_1.png"],
[UIImage imageNamed:@"win_2.png"],
[UIImage imageNamed:@"win_3.png"],
[UIImage imageNamed:@"win_4.png"],
[UIImage imageNamed:@"win_5.png"],
[UIImage imageNamed:@"win_6.png"],
[UIImage imageNamed:@"win_7.png"],
[UIImage imageNamed:@"win_8.png"],
[UIImage imageNamed:@"win_9.png"],
[UIImage imageNamed:@"win_10.png"],
[UIImage imageNamed:@"win_11.png"],
[UIImage imageNamed:@"win_12.png"],
[UIImage imageNamed:@"win_13.png"],
[UIImage imageNamed:@"win_14.png"],
[UIImage imageNamed:@"win_15.png"],nil];
CAKeyframeAnimation *animationSequence = [CAKeyframeAnimation animationWithKeyPath: @"contents"];
animationSequence.calculationMode = kCAAnimationLinear;
animationSequence.autoreverses = NO;
animationSequence.duration = 0.90;
animationSequence.repeatCount = HUGE_VALF;
animationSequence.beginTime = 0;
NSMutableArray *animationSequenceArray = [[NSMutableArray alloc] init];
for (UIImage *image in animationImages)
{
[animationSequenceArray addObject:(id)image.CGImage];
}
CALayer *layer = [upwardView layer];
animationSequence.values = animationSequenceArray;
[layer addAnimation:animationSequence forKey:@"contents"];
Upvotes: 0
Views: 59
Reputation: 4825
Why are you adding upwardView to self.view and self.stageView? Remove this
[self.stageView addSubview:upwardView];
line. It should work perfectly.
Upvotes: 1