#import "ViewController.h"
typedef enum
{
// 1 2 4 8
ZHLocationTypeTop = 1<< 0,
ZHLocationTypeBottom = 1<< 1,
ZHLocationTypeLeft = 1 << 2,
ZHLocationTypeRight = 1 << 3
}ZHLocationType;
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"%d" ,ZHLocationTypeRight);
// 可以传多个值,如果传0 ,默认什么操作不做
// [self test:0];
[self test:ZHLocationTypeRight | ZHLocationTypeTop];
}
- (void) test :(ZHLocationType) type
{
if (type & ZHLocationTypeTop) {
NSLog(@"上");
}
if (type & ZHLocationTypeLeft) {
NSLog(@"左");
}
if (type & ZHLocationTypeBottom) {
NSLog(@"下");
}
if (type & ZHLocationTypeRight) {
NSLog(@"右");
}
}
@end
09-27
09-27
09-27