Open MaxGraey opened 12 years ago
In the example presented below:
UIView animateWithDuration:1.5 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^(void) { // property animations } completion:nil ];
the argument "options" always takes the same value (UIViewAnimationCurveEaseInOut) regardless of actual value. The fact that the implementation of that method lies the error. In this situation you can not work with enums as with bit-fields!
If we replace this:
// In UIView // + (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay // options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion
if ((options & UIViewAnimationOptionCurveEaseInOut) == UIViewAnimationOptionCurveEaseInOut) { animationCurve = UIViewAnimationCurveEaseInOut; } else if ((options & UIViewAnimationOptionCurveEaseIn) == UIViewAnimationOptionCurveEaseIn) { animationCurve = UIViewAnimationCurveEaseIn; } else if ((options & UIViewAnimationOptionCurveEaseOut) == UIViewAnimationOptionCurveEaseOut) { animationCurve = UIViewAnimationCurveEaseOut; } else { animationCurve = UIViewAnimationCurveLinear; }
On simple:
animationCurve = (options >> 16) & 0x03;
Then the behavior will be correct
In the example presented below:
UIView animateWithDuration:1.5 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^(void) { // property animations } completion:nil ];
the argument "options" always takes the same value (UIViewAnimationCurveEaseInOut) regardless of actual value. The fact that the implementation of that method lies the error. In this situation you can not work with enums as with bit-fields!
If we replace this:
// In UIView // + (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay // options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion
if ((options & UIViewAnimationOptionCurveEaseInOut) == UIViewAnimationOptionCurveEaseInOut) { animationCurve = UIViewAnimationCurveEaseInOut; } else if ((options & UIViewAnimationOptionCurveEaseIn) == UIViewAnimationOptionCurveEaseIn) { animationCurve = UIViewAnimationCurveEaseIn; } else if ((options & UIViewAnimationOptionCurveEaseOut) == UIViewAnimationOptionCurveEaseOut) { animationCurve = UIViewAnimationCurveEaseOut; } else { animationCurve = UIViewAnimationCurveLinear; }
On simple:
animationCurve = (options >> 16) & 0x03;
Then the behavior will be correct