2 peterchen149 peterchen149 于 2016.03.18 16:10 提问

使用CAKeyframeAnimation导致导航栏的pop动画卡顿
ios

我的一个提示框消失的时候,使用自定义的动画,用了CAKeyframeAnimation,此提示框消失的同时,导航栏执行pop viewcontroller操作,这时候,就出现了pop特效有卡顿的现象,如果我用UIView 的animateWithDuration 方法执行那个自定义的动画或者用uialertview代替我自己的提示框,pop特效就很流畅,这是什么原因呢?

代码如下:

 -(void)hideOnPopAnimation{
    dispatch_async(dispatch_get_main_queue(), ^{
        CAKeyframeAnimation *hideAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
        hideAnimation.duration = kDefaultAnimationDuration;
        hideAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.1, 1.1, 1.0)],
                                 [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.5,0.5 , 1.0)],
                                 [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.0, 0.0, 0.0)]
                                 ];
        hideAnimation.keyTimes = @[@0.2,@0.5,@1];
        hideAnimation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
                                          [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
                                          [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
        hideAnimation.delegate = self;
    hideAnimation.removedOnCompletion = NO;
    hideAnimation.fillMode = kCAFillModeForwards;
        [self.layer addAnimation:hideAnimation forKey:nil];
    });
}
-(void)hideOnPopAnimation{
    [UIView animateWithDuration:kDefaultAnimationDuration animations:^{
        self.transform  = CGAffineTransformMakeScale(0.01, 0.01);
    } completion:^(BOOL finished) {
        [self destroy];
    }];
}
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!