两种方案:
1:枚举NS_ENUM大部分单个使用:
typedef NS_ENUM(NSInteger, Test) {
TestA = 1, //1 1 1
TestB = 1 << 1, //2 2 10 转换成 10进制 2
TestC = 1 << 2, //4 3 100 转换成 10进制 4
TestD = 1 << 3, //8 4 1000 转换成 10进制 8
TestE = 1 << 4 //16 5 10000 转换成 10进制 16
};
2:枚举NS_OPTIONS 可以多个拼接使用,通过位移实现:
typedef NS_OPTIONS(NSUInteger, UIViewAutoresizing) {
UIViewAutoresizingNone = 0,
UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
UIViewAutoresizingFlexibleWidth = 1 << 1,
UIViewAutoresizingFlexibleRightMargin = 1 << 2,
UIViewAutoresizingFlexibleTopMargin = 1 << 3,
UIViewAutoresizingFlexibleHeight = 1 << 4,
UIViewAutoresizingFlexibleBottomMargin = 1 << 5
};
使用:
UIViewAutoresizing option = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin;
NSLog(@"%ld",option);