美文网首页
常用的宏定义

常用的宏定义

作者: 无所待 | 来源:发表于2016-11-17 17:27 被阅读0次

//获取屏幕 宽度、高度

//宽度

#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)

//高度

#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)

// rgb颜色转换(16进制->10进制)

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

// 可以更改透明度

#define UIColorFromRGBA(rgbValue,a) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:a]

#ifdef DEBUG

#define ZKLog(fmt, ...) NSLog((@"%s [Line %d] "  fmt),__PRETTY_FUNCTION__,__LINE__,##__VA_ARGS__);

#else

#define ZKLog(...)

#endif

像素与尺寸的关系

[UIScreen mainScreen].scale

//当前版本

#define IOS_FSystenVersion ([[[UIDevice currentDevice] systemVersion] floatValue])

#define IOS_DSystenVersion ([[[UIDevice currentDevice] systemVersion] doubleValue])

#define IOS_SSystemVersion ([[UIDevice currentDevice] systemVersion])

//当前语言

#define CURRENTLANGUAGE ([[NSLocale preferredLanguages] objectAtIndex:0])

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000

#define Textsize(text, font, maxWith) [text length] > 0 ? [text \\

boundingRectWithSize:CGSizeMake(maxWith, MAXFLOAT) options:(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading) \\

attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:font]} context:nil].size : CGSizeZero;

#else

#define Textsize(text, font, maxWith) [text length] > 0 ? [text \\

sizeWithFont:[UIFont systemFontOfSize:font] constrainedToSize:CGSizeMake(maxWith, MAXFLOAT)] : CGSizeZero;

#endif

// 大于等于IOS7

#define RC_MULTILINE_TEXTSIZE_GEIOS7(text, font, maxSize) [text length] > 0 ? [text \\

boundingRectWithSize:maxSize options:(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading) \\

attributes:@{NSFontAttributeName:font} context:nil].size : CGSizeZero;

// 小于IOS7

#define RC_MULTILINE_TEXTSIZE_LIOS7(text, font, maxSize, mode) [text length] > 0 ? [text \\

sizeWithFont:font constrainedToSize:maxSize lineBreakMode:mode] : CGSizeZero;

相关文章

  • iOS 常用宏定义

    常用宏定义

  • iOS 常用宏定义

    iOS 开发中使用一些常用宏定义可以大大提高开发效率,提高代码的重用性.以下是一些常用的宏定义: 像这些宏定义,在...

  • 宏定义指令

    常用的宏定义指令 详细应用

  • iOS开发常用的宏定义

    Objective-C常用宏/*! 字体 */ /*! 颜色宏定义 */ /*! 弱引用宏 */ /*! 输出显示...

  • 常用宏定义

    // HGBMacroConfig.h #ifndef HGBMacroConfig_h #define HGBM...

  • 常用宏定义

    //屏幕尺寸 define SCREEN_WIDTH [UIScreen mainScreen].bounds...

  • 常用宏定义

    1.color #define COlOR(R,G,B,A) [UIColor colorWithRed:(R)/...

  • 常用宏定义

    1、屏幕尺寸 2、UIView相关 3、常用颜色 4、手机版本 5、沙盒

  • 常用宏定义

    未完待续 持续更新中 1. 字符串判空处理 2.获取屏幕宽高 3.Log输出样式修改 呈现效果 4.宏定义单例 5...

  • 常用宏定义

    优点 提高了程序的可读性,同时也方便进行修改,用户只需要在一处定义,多处使用,修改也只需要修改一处 提高程序的运行...

网友评论

      本文标题:常用的宏定义

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