iOS Developer

iOS-枚举的<<

2017-06-22  本文已影响21人  linbj
enum UIViewAutoresizing {
UIViewAutoresizingNone = 0,
UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
UIViewAutoresizingFlexibleWidth = 1 << 1,
UIViewAutoresizingFlexibleRightMargin = 1 << 2,
UIViewAutoresizingFlexibleTopMargin = 1 << 3,
UIViewAutoresizingFlexibleHeight = 1 << 4, 
UIViewAutoresizingFlexibleBottomMargin = 1 << 5,
}”

这个<<是什么意思?

位操作法,即往左移动N位,举个例子,1的二进制表示是1,往左移一位就是10。这种枚举是一般叫做option。举个例子UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth就是 01 | 10 即11

顺便提一下动画的枚举


0A7BB0BB-621A-4548-807D-4475164E4EF5.png
typedef NS_OPTIONS(NSUInteger, UIViewAnimationOptions) {
  UIViewAnimationOptionLayoutSubviews            = 1 <<  0, //提交动画的时候布局子控件,表示子控件将和父控件一同动画。
    UIViewAnimationOptionAllowUserInteraction      = 1 <<  1,  //动画时允许用户交流,比如触摸
    UIViewAnimationOptionBeginFromCurrentState     = 1 <<  2, //从当前状态开始动画
    UIViewAnimationOptionRepeat                    = 1 <<  3, //动画无限重复
    UIViewAnimationOptionAutoreverse               = 1 <<  4,  //执行动画回路,前提是设置动画无限重复
    UIViewAnimationOptionOverrideInheritedDuration = 1 <<  5, //忽略外层动画嵌套的执行时间
    UIViewAnimationOptionOverrideInheritedCurve    = 1 <<  6,  //忽略外层动画嵌套的时间变化曲线
    UIViewAnimationOptionAllowAnimatedContent      = 1 <<  7, //通过改变属性和重绘实现动画效果,如果key没有提交动画将使用快照
    UIViewAnimationOptionShowHideTransitionViews   = 1 <<  8, //用显隐的方式替代添加移除图层的动画效果
    UIViewAnimationOptionOverrideInheritedOptions  = 1 <<  9, //忽略嵌套继承的�选项
    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,//下卷转场
    UIViewAnimationOptionTransitionCrossDissolve   = 5 << 20,//转场交叉消失
    UIViewAnimationOptionTransitionFlipFromTop     = 6 << 20,//转场从上翻转
    UIViewAnimationOptionTransitionFlipFromBottom  = 7 << 20,//转场从下翻转

} NS_ENUM_AVAILABLE_IOS(4_0);
上一篇 下一篇

猜你喜欢

热点阅读