#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];
}];
}
- (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就好了 ,代码参考