iOS开发常用宏

来源:互联网 发布:轻松赚软件怎么样 编辑:程序博客网 时间:2024/06/06 12:53

#define RELEASE(obj) { [obj release]; obj = nil; }



//是否arc

#if ! __has_feature(objc_arc)

    [xxx release];

#endif

//判断是真机还是模拟器

#if TARGET_OS_IPHONE

//iPhone Device

#endif


#if TARGET_IPHONE_SIMULATOR

//iPhone Simulator

#endif




///是否iPad

#define IPAD UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad


///是否iPhone

#define IPHONE UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone


///版本

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


///是否 ios7

#define IOS7 (VERSION>=7.0)


//return 1pt所占px

#define SCALE ([UIScreen mainScreen].scale)


///系统屏幕大小

#define WIN_SIZE ([UIScreen mainScreen].bounds.size)

//是否Retina

#define IS_Retina (SCALE>=2.0)


///颜色

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


//返回angle(float) degrees(360)

#define angleForDegrees(degrees) (M_PI * (degrees) / 180.0)


0 0