程序员iOS Developer@IT·互联网

iOS开发 枚举类型NS_ENUM和NS_OPTIONS的区别

2016-06-21  本文已影响552人  槑头脑

NS_ENUM

通用枚举值

typedef NS_ENUM(NSInteger, UIControlContentHorizontalAlignment) {
    UIControlContentHorizontalAlignmentCenter = 0,
    UIControlContentHorizontalAlignmentLeft   = 1,
    UIControlContentHorizontalAlignmentRight  = 2,
    UIControlContentHorizontalAlignmentFill   = 3,
};

NS_OPTIONS

位移相关操作的枚举值

typedef NS_OPTIONS(NSUInteger, UIControlState) {
    UIControlStateNormal       = 0,
    UIControlStateHighlighted  = 1 << 0,
    UIControlStateDisabled     = 1 << 1,
    UIControlStateSelected     = 1 << 2,
    UIControlStateApplication  = 0x00FF0000,
    UIControlStateReserved     = 0xFF000000
};

self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

给个喜欢喔O(∩_∩)O


上一篇下一篇

猜你喜欢

热点阅读