Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do different block animation constants have the same value?

UIViewAnimationOptions
Options for animating views with blocks.

enum {
   UIViewAnimationOptionLayoutSubviews            = 1 <<  0,
   UIViewAnimationOptionAllowUserInteraction      = 1 <<  1,
   UIViewAnimationOptionBeginFromCurrentState     = 1 <<  2,
   UIViewAnimationOptionRepeat                    = 1 <<  3,
   UIViewAnimationOptionAutoreverse               = 1 <<  4,
   UIViewAnimationOptionOverrideInheritedDuration = 1 <<  5,
   UIViewAnimationOptionOverrideInheritedCurve    = 1 <<  6,
   UIViewAnimationOptionAllowAnimatedContent      = 1 <<  7,
   UIViewAnimationOptionShowHideTransitionViews   = 1 <<  8,

   UIViewAnimationOptionCurveEaseInOut            = 0 << 16,
   UIViewAnimationOptionCurveEaseIn               = 1 << 16,
   UIViewAnimationOptionCurveEaseOut              = 2 << 16,
   UIViewAnimationOptionCurveLinear               = 3 << 16,

   UIViewAnimationOptionTransitionNone            = 0 << 20,
   UIViewAnimationOptionTransitionFlipFromLeft    = 1 << 20,
   UIViewAnimationOptionTransitionFlipFromRight   = 2 << 20,
   UIViewAnimationOptionTransitionCurlUp          = 3 << 20,
   UIViewAnimationOptionTransitionCurlDown        = 4 << 20,
};
typedef NSUInteger UIViewAnimationOptions;

Consider the about enum definitions from the iOS documentation. My question is :
For UIViewAnimationOptionCurveEaseInOut, the constant is "0 << 16", but if my understanding is correct, 0 left shift by 16 positions is still 0. And it should be the same as UIViewAnimationOptionTransitionNone which is "0 << 20" (since it should also be 0). Having 2 very different options equal to the same value does not seem to make sense.

Also, my testing shows UIViewAnimationOptionCurveEaseInOut does not seem to have any effect at all.

There could be some misunderstanding on my part, hope that somebody knowledgeable would help ...

http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIView_Class/UIView/UIView.html%23//apple_ref/c/tdef/UIViewAnimationOptions

like image 582
Stanley Avatar asked Jun 22 '11 14:06

Stanley


1 Answers

All options, that are equal to 0 are default settings, so if you dont pass in any option is the same as passing in (UIViewAnimationOptionCurveEaseInOut| UIViewAnimationOptionTransitionNone) or just 0

like image 191
vikingosegundo Avatar answered Oct 13 '22 10:10

vikingosegundo