iOS 动画无限循环CPU占用过高处理

#define WS(weakSelf)  __weak __typeof(&*self)weakSelf = self;


- (void)startAnimation

{

    WS(weakSelf);

    CGAffineTransform endAngle = CGAffineTransformMakeRotation(angle * (M_PI / 180.0f));

    [UIView animateWithDuration:0.1 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{

        self.ImageView.transform = endAngle;


    } completion:^(BOOL finished) {

        angle += 2;

        [weakSelf performSelector:@selector(startAnimation) withObject:nil afterDelay:0.01];

    }];


}

用上weakSelf就好了 ,代码参考

猜你喜欢

转载自blog.csdn.net/chengqiang0414/article/details/80953066
今日推荐