为什么不同的块动画常量具有相同的值?

时间:2011-06-22 14:54:48

标签: ios objective-c cocoa-touch ios4

UIViewAnimationOptions
使用块动画视图的选项。

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;

考虑iOS文档中的枚举定义。 我的问题是:
对于UIViewAnimationOptionCurveEaseInOut,常量是“0 <&lt; 16”,但是如果我的理解是正确的,那么左移16个位置的0仍然是0.它应该与UIViewAnimationOptionTransitionNone相同,即“0 <&lt; 20” (因为它也应该是0)。有两个非常不同的选项等于相同的值似乎没有意义。

另外,我的测试显示UIViewAnimationOptionCurveEaseInOut似乎根本没有任何效果。

我可能会有一些误解,希望知识渊博的人会有所帮助...

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

1 个答案:

答案 0 :(得分:7)

所有等于0的选项都是默认设置,因此如果您没有传入任何选项,则与传入(UIViewAnimationOptionCurveEaseInOut| UIViewAnimationOptionTransitionNone)0

相同