Stop animation when same time remove button from superview
<p>if i tap on button then this button is animate with rotation and add once again in self.view, but i want to when this button is add in view more than 10 in self.view then remove first button, and next animation is not stop, i want to remove button in another thread, but not effect on animation </p>

<p>I Try that code for another thread, but not work properly, animation is stop</p>

<pre><code>-(void)putFruietAtOriginPositionInMainThread:(NSDictionary*)btnDictionary{
    //if (!dragFlag) {
        [self playSoundEffect:@"abc.mp3" withRepeatCount:0];
        //[self.view bringSubviewToFront:btnBag];
        //[self.view bringSubviewToFront:bagView];
        UIButton *btnFruiet = [btnDictionary objectForKey:@"btnFruiet"];
        int  position= [[btnDictionary objectForKey:@"position"]intValue];
        CGFloat xPosition = [[[dicCenterPoint objectForKey:[NSString stringWithFormat:@"%i",btnFruiet.tag]] objectAtIndex:0]floatValue];
        CGFloat yPosition = [[[dicCenterPoint objectForKey:[NSString stringWithFormat:@"%i",btnFruiet.tag]] objectAtIndex:1]floatValue];
        btnFruiet.center = self.view.center;
        //btnFruiet.enabled = FALSE;
        //[self playSoundEffect:@"shapes_collapse.mp3" withRepeatCount:0];

        if ([dicFruitTimer count]&gt;0) {
            NSTimer *timer = [dicFruitTimer valueForKey:[NSString stringWithFormat:@"%i",btnFruiet.tag]];
            if (timer) {
                [timer invalidate];
                timer=nil;
                [dicFruitTimer removeObjectForKey:[NSString stringWithFormat:@"%i",btnFruiet.tag]];
            }
        }
        NSTimer *fruitTimer = [NSTimer timerWithTimeInterval:0.00002 target:self selector:@selector(setFrameOfFruietWithTimer:) userInfo:[NSDictionary dictionaryWithObject:btnFruiet forKey:@"fruit"] repeats:YES];
        [[NSRunLoop mainRunLoop]addTimer:fruitTimer forMode:NSRunLoopCommonModes];
        [dicFruitTimer setObject:fruitTimer forKey:[NSString stringWithFormat:@"%i",btnFruiet.tag]];


        [CATransaction begin];
        [CATransaction setValue:[NSNumber numberWithFloat:FRUIT_ANIMATION_DURATION/2] forKey:kCATransactionAnimationDuration];

        CAKeyframeAnimation *positionAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
        CGMutablePathRef positionPath = CGPathCreateMutable();
        CGPathMoveToPoint(positionPath, NULL, [btnFruiet layer].position.x , [btnFruiet layer].position.y);
        CGPathAddLineToPoint(positionPath, NULL, xPosition,  yPosition);
        positionAnimation.path = positionPath;

        //CABasicAnimation *rotateAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
        //  rotateAnimation.delegate = self;
        //  //rotateAnimation.autoreverses = YES;
        //  rotateAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
        //  rotateAnimation.fromValue = [NSNumber numberWithFloat:2.0];
        //  rotateAnimation.toValue = [NSNumber numberWithFloat:1.0];
        //  rotateAnimation.fillMode = kCAFillModeForwards;
        //  rotateAnimation.removedOnCompletion = NO;

        CABasicAnimation *shrinkAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
        shrinkAnimation.fromValue = [NSNumber numberWithFloat:kScaleFactor];
        shrinkAnimation.toValue = [NSNumber numberWithFloat:1.0f];

        CAAnimationGroup *theGroup = [CAAnimationGroup animation];
        theGroup.delegate = self;
        theGroup.removedOnCompletion = NO;
        theGroup.fillMode = kCAFillModeForwards;
        theGroup.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
        theGroup.animations = [NSArray arrayWithObjects:positionAnimation,  shrinkAnimation,nil];
        NSString *strPosition = [NSString stringWithFormat:@"%d,3", position];
        [theGroup setValue:strPosition forKey:@"AnimationGroup"];
        [[btnFruiet layer] addAnimation:theGroup forKey:@"AnimationGroup"];
    //btnAnimationRunning = btnFruiet;
        [CATransaction commit];
        CGPathRelease(positionPath);
        //[arrTimers removeObject:timer];
    //}

    if ([arrFruitOnScreen count]&gt;10) {


        //NSThread *thread = [[NSThread alloc] init];
        //[self performSelector:@selector(removeFruit) withObject:nil];
        [self performSelector:@selector(removeFruit) withObject:nil afterDelay:FRUIT_ANIMATION_DURATION/2];
        //[thread start];
        //[self performSelector:@selector(removeFruit) onThread:thread withObject:nil waitUntilDone:NO];
    //}

}


-(void)removeFruit{

    UIButton *btnF = [arrFruitOnScreen objectAtIndex:0];
    [[btnF layer] removeAllAnimations];
    [arrFruitOnScreen removeObjectAtIndex:0];
    [btnF removeFromSuperview];


}
</code></pre>
