BigZaphod / Chameleon

Chameleon is a port of Apple's UIKit for iOS (and some minimal related frameworks) to Mac OS X.
http://chameleonproject.org/
BSD 3-Clause "New" or "Revised" License
3.45k stars 572 forks source link

NSView animateWithDuration always takes UIViewAnimationCurveEaseInOut option #77

Open MaxGraey opened 12 years ago

MaxGraey commented 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