請問@synchronized鎖直到動畫結束?@synchronized [UIView animationWithDuration ...]鎖定結束?
__weak typeof(sharedManager) weakManager = sharedManager;
^(CMDeviceMotion *motion, NSError *error)
{
@synchronized(weakManager)
{ ... some code
if (angle != sharedManager.angle)
{
if (sharedManager.isLocked) return;
sharedManager.locked = YES;
sharedManager.angle = angle;
CGAffineTransform transform = (angle == 0) ?
CGAffineTransformIdentity : CGAffineTransformMakeRotation(angle);
sharedManager.currentTransform = transform;
[UIView animateWithDuration:.25
animations:^
{
[weakManager.animatedViews setValue:[NSValue valueWithCGAffineTransform:transform]
forKey:@"transform"];
}
completion:^(BOOL finished)
{
weakManager.locked = NO;
}];
}
}
}];
感謝您的回答 –