iOS - 常用的一些宏定义

extern BOOL whetherHaveNetwork;

/**  动画时间  */

static const NSTimeInterval YDAnimateTime = 0.5;

//#define YDAnimateTime 0.5

/** 无数据时的提示文字*/

#define noGoodsRemaindText    @"当前无数据,请管理员云平台上传!"

/**  RGB颜色  */

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

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

#define YDColorFromRGB(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 YDRandomColor kColor(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256))

/**  系统主题颜色  */

#define YDSystemColor YDColor(15, 23, 27)

/**  每一页的数据  */

#define YDLimitPageNum @(20)

/**  注册 tableView  */

#define YDRegisterTableViewNib(tableView,nibName) [tableView registerNib:[UINib nibWithNibName:nibName bundle:nil] forCellReuseIdentifier:nibName]

/**  注册 CollectionView  */

#define YDRegisterCollectionViewNib(collectionView,nibName) [collectionView registerNib:[UINib nibWithNibName:nibName bundle:nil] forCellWithReuseIdentifier:nibName]

/**  弱引用  */

#define YDWeakSelf __weak typeof(self) weakSelf = self;

/**  沙盒Document路径  */

#define YDDocumentPath ([NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject])

/**  沙盒Cache路径  */

#define YDCachePath ([NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject])

/**  屏幕高度  */

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

/**  屏幕宽度  */

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

/**  弧度转角度  */

#define YDRADIANS_TO_DEGREES(radians) ((radians) * (180.0 / M_PI))

/**  角度转弧度  */

#define YDDEGREES_TO_RADIANS(angle) ((angle) / 180.0 * M_PI)

/**  是否为iOS7  */

#define iOS7 ([[UIDevice currentDevice].systemVersion doubleValue] >= 7.0)

/**  是否为4inch  */

#define FourInch ([UIScreen mainScreen].bounds.size.height >= 568.0)

注意,要配置之才可在全局使用


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • iOS开发过程中,使用的一些常用宏定义 字符串是否为空#define kStringIsEmpty(str) ([...
    goyohol阅读 5,397评论 30 85
  • 大家都是知道开发中使用宏不仅方便,而且可以提高开发效率, 代码清晰易懂。下面我总结了我在做iOS开发时的一些常用宏...
    AbnerZhang阅读 381评论 0 2
  • 前言: 在工作中, 很多小伙伴都会在PCH文件定义一些常用的宏,但是又怕写这些简单的宏浪费时间,又有时候忘记怎么定...
    sherry155阅读 482评论 0 0
  • /**获取屏幕宽度与高度 导航,tabbar高度*/ #define SCREEN_WIDTH [UIScree...
    MUYO_echo阅读 710评论 0 3
  • 一眉弯月 勾破了夜空墨色的斗篷 群星暗淡 如同看不到光亮的征程 诗和远方 是心中炽热的梦想 焦躁和疯狂 错失对沿途...
    艾弥儿阅读 470评论 8 16