IOS开发 一些常用的宏定义

根据个人使用习惯  自行修改Macro_前缀


//基础引用

#define GJH(key)                NSLocalizedString(key, comment)

#define WS(weakSelf)            __weak __typeof(&*self)weakSelf = self;

#define App_Keywindow [UIApplication sharedApplication].delegate.window

#define App_Delegate (AppDelegate *)[UIApplication sharedApplication].delegate

#define NIB(name,bundleName)    ([UINib nibWithNibName:name bundle:bundleName])

//设备相关

#define Macro_ScreenBounds          [UIScreen mainScreen].bounds

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

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

#define Macro_Is_iphone              (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)

#define Macro_Is_ipad                ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)

#define Macro_Is_iPhoneX            (Macro_ScreenWidth >=375.0f&& Macro_ScreenHeight >=812.0f&& Macro_Is_iphone)

#define Macro_ScreenScale            (Macro_Is_ipad  ?1.3  :(Macro_ScreenWidth /375) )

//尺寸  iphonex 之后有safe 安全区域 概念

// Tabbar safe Top margin.

#define Macro_TabbarSafeTopMargin        (LL_iPhoneX ?44.f:0.f)

// Tabbar safe bottom margin.

#define Macro_TabbarSafeBottomMargin        (LL_iPhoneX ?34.f : 0.f)//[[[UIApplication sharedApplication] delegate] window].safeAreaInsets.bottom

// Navigation bar height.

#define  Macro_NavigationBarHeight  44.f

// Tabbar height.

#define Macro_TabbarHeight        (LL_iPhoneX ? (49.f+34.f) :49.f)

// Status bar height.

#define Macro_StatusBarHeight      (Macro_Is_iPhoneX ?44.f : 20.f)//[[UIApplication sharedApplication] statusBarFrame].size.height

// Status bar & navigation bar height.

#define Macro_StatusBarAndNavigationBarHeight  (LL_iPhoneX ?88.f:64.f)

//颜色

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

#define Macro_ColorRGB(r, g, b)    Macro_ColorRGBA(r, g, b,1.0)

#define Macro_Color16RGBA(rgbValue, alphaValue) [UIColor \

colorWithRed:((float)((rgbValue &0xFF0000) >>16))/255.0\

green:((float)((rgbValue &0x00FF00) >>8))/255.0\

blue:((float)(rgbValue &0x0000FF))/255.0\

alpha:alphaValue]

#define Macro_Color16RGB(rgbValue) Macro_Color16RGBA(rgbValue,1.0)

#define Macro_ColorRand  [UIColor colorWithRed:arc4random()%255/255.0fgreen:arc4random()%255/255.0fblue:arc4random()%255/255.0falpha:1.0f]

你可能感兴趣的:(IOS开发 一些常用的宏定义)