Objective-C 枚举
typedef NS_ENUM(NSInteger,LineDirection){
LineDirectionTop = 1 << 0,
LineDirectionBottom = 1 << 1,
LineDirectionLeft = 1 << 2,
LineDirectionRight = 1 << 3
};
objective-C & 与运算判断举例
if (direction & LineDirectionTop) {
}
Swift 枚举
enum LineDirection:UInt8 {
case top = 0b0001
case bottom = 0b0010
case left = 0b0100
case right = 0b1000
}
Swift & 与运算判断举例
if (direction.rawValue & LineDirection.top.rawValue) != 0b000 ){
}