美文网首页iOS
OC 常用宏

OC 常用宏

作者: Hellmessage | 来源:发表于2017-04-06 23:48 被阅读8次

    //常用宏

    #define Maxw[[UIScreen mainScreen] bounds].size.width

    #define Maxh[[UIScreen mainScreen] bounds].size.height

    #define WS(ws)__weak __typeof(self) ws = self

    #define SS(ss)__strong __typeof(ws)ss = ws

    #define CG(x,y,w,h)CGRectMake(x,y,w,h)

    #define CS(w,h)CGSizeMake(w,h)

    #define Img(imageName)[UIImage imageNamed:[NSString stringWithFormat:@"%@",imageName]]

    #define RGB(rgb)[UIColor colorWithRed:((float)((rgb &0xFF0000) >>16))/255.0green:((float)((rgb &0xFF00) >>8))/255.0blue:((float)(rgb &0xFF))/255.0alpha:1.0]

    #define RGBA(r,g,b,a)[UIColor colorWithRed:r/255.0green:g/255.0blue:b/255.0alpha:a]

    #define CGRGBA(r,g,b,a)[[UIColor colorWithRed:r/255.0green:g/255.0blue:b/255.0alpha:a] CGColor]

    #define FONT(a)[UIFont systemFontOfSize:a]

    #define X(v)(v).frame.origin.x

    #define Y(v)(v).frame.origin.y

    #define W(v)(v).frame.size.width

    #define H(v)(v).frame.size.height

    #define MinX(v)CGRectGetMinX((v).frame)

    #define MinY(v)CGRectGetMinY((v).frame)

    #define MidX(v)CGRectGetMidX((v).frame)

    #define MidY(v)CGRectGetMidY((v).frame)

    #define MaxX(v)CGRectGetMaxX((v).frame)

    #define MaxY(v)CGRectGetMaxY((v).frame)

    #define AVERAGE(MAX,MIN,NUM)(MAX - MIN) / NUM

    #define HERadiusTLUIRectCornerTopLeft

    #define HERadiusTRUIRectCornerTopRight

    #define HERadiusBLUIRectCornerBottomLeft

    #define HERadiusBRUIRectCornerBottomRight

    //获取版本

    #define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]

    #define CurrentSystemVersion [[UIDevice currentDevice] systemVersion]

    //当前应用版本号

    #define AppVersion [[NSBundle mainBundle] infoDictionary][@"CFBundleVersion"]

    #pragma mark - DEBUG#else

    //定义是输出Log

    #define DLog(format, ...)

    #endif

    //只输出类名

    #define LogClassName DLog(@"")

    #ifdef DEBUG

    #define ULog(fmt, ...){ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%s\n [Line %d] ", __PRETTY_FUNCTION__, __LINE__] message:[NSString stringWithFormat:fmt, ##__VA_ARGS__]delegate:nil cancelButtonTitle:@"Ok"otherButtonTitles:nil]; [alert show]; }

    #else

    #define ULog(...)

    #endif

    #ifdef DEBUG

    //定义是输出Log

    #define DLog(format, ...) NSLog(@"Line[%d] %s "format, __LINE__, __PRETTY_FUNCTION__,##__VA_ARGS__)

    相关文章

      网友评论

        本文标题:OC 常用宏

        本文链接:https://www.haomeiwen.com/subject/vohfattx.html