常用宏定义

1.color

#define COlOR(R,G,B,A)  [UIColor colorWithRed:(R)/255.0 green:(G)/255.0 blue:(B)/255.0 alpha:(A)]

2.屏幕大小

#define ScreenBounds [[UIScreen mainScreen] bounds]

//屏幕高度

#define ScreenHeight ScreenBounds.size.height

//屏幕宽度

#define ScreenWidth ScreenBounds.size.width

//导航栏

#define NAVHEIGHT  64

#define TABBARHEIGHT   49


3.版本号

#define VERSION  (NSString *)[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]

#define SystemVersion   [[UIDevice currentDevice] systemVersion]


4.字体

#define SystemFont(fontSize)  [UIFont systemFontOfSize:fontSize];

#define SystemBoldFont(fontSize)  [UIFont boldSystemFontOfSize:fontSize];

5.


#define  MPUserDefaults  [NSUserDefaults  standardUserDefaults]

#define MPNotificationCenter [NSNotificationCenter defaultCenter]

#define MPAPPLICATION  [UIApplication sharedApplication]

#define  WINDOW  [MPAPPLICATION keyWindow]


6.

#define   BUNDLEID     (NSString *)[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]

7.

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

#define ImageNamed(imgNameStr)   [UIImage imageNamed:imgNameStr]

#define StrWithF(S)    [NSString stringWithFormat:@"%@",S]

//字符串是否为空

#define StringIsEmpty(str)   ([str isKindOfClass:[NSNull class]] || str == nil || [str length] <1? YES : NO )

//数组是否为空

#define ArrayIsEmpty(array)     (array == nil || [array isKindOfClass:[NSNull class]] || array.count ==0)

//字典是否为空

#define DictIsEmpty(dic)   (dic == nil || [dic isKindOfClass:[NSNull class]] || dic.allKeys ==0)

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

推荐阅读更多精彩内容

  • iOS开发过程中,使用的一些常用宏定义 字符串是否为空#define kStringIsEmpty(str) ([...
    goyohol阅读 10,727评论 30 85
  • [转自:iOS常用宏定义][http://www.cocoachina.com/ios/20161207/1831...
    MMOTE阅读 3,984评论 3 3
  • 字符串是否为空 #define kStringIsEmpty(str) ([str isKindOfClass:[...
    cocoaZ阅读 2,523评论 0 0
  • //字符串是否为空 #define kStringIsEmpty(str) ([str isKindOfClass...
    __life__阅读 3,146评论 0 0
  • 以诚相待-三故茅庐,知己知彼- 百战不殆,目光短浅-蜀汉休矣,心胸狭隘-自取灭亡,心胸宽广-唯才是举,志向高远一统天下。
    若琪阅读 1,553评论 0 0