位移枚举

2016-12-12  本文已影响16人  哔哩哔哩智能喵
/**
 * 普通枚举
 */
typedef NS_ENUM(NSInteger,XCType)
{
    XCTypeTop,
    XCTypeBottom
};
/**
 * 位移枚举
   一个参数可以传递多个值
   如果是位移枚举,观察第一个枚举值,如果该枚举值!=0,那么可以默认传0,如果传0做参数,那么效率最高
 */
typedef NS_OPTIONS(NSInteger, XCTypec) {
    XCTypecTop = 1<<0,//1*2的0次方 = 1
    XCTypecBottom = 1<<1,//1*2的1次方 = 2
    XCTypecLeft = 1<<2,//1*2的2次方 = 4
    XCTypecRight = 1<<3//1*2的3次方 = 8
};

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self test: XCTypecTop | XCTypecLeft |XCTypecRight];
}
-(void)test:(XCTypec)typec
{
    NSLog(@"%ld",(long)typec);
    if (typec & XCTypecTop) {
        NSLog(@"-%zd",typec & XCTypecTop);
        
    }
    if (typec & XCTypecLeft) {
        NSLog(@"---%zd",typec & XCTypecLeft);
        
    }
    if (typec & XCTypecRight) {
        NSLog(@"----%zd",typec & XCTypecRight);
        
    }
}
-
[self.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://img4.duitang.com/uploads/blog/201310/18/20131018213446_smUw4.thumb.600_0.jpeg"] placeholderImage:[UIImage imageNamed:@"Snip20160221_306"] options:SDWebImageCacheMemoryOnly | SDWebImageProgressiveDownload progress:^(NSInteger receivedSize, NSInteger expectedSize) {
        
    } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        
        switch (cacheType) {
            case SDImageCacheTypeNone:
                NSLog(@"直接下载");
                break;
            case SDImageCacheTypeDisk:
                NSLog(@"磁盘缓存");
                break;
            case SDImageCacheTypeMemory:
                NSLog(@"内存缓存");
                break;
            default:
                break;
        }
    }];
上一篇下一篇

猜你喜欢

热点阅读