BGSystemMacro.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // BGSystemMacro.h
  3. // BuguLive
  4. //
  5. // Created by xfg on 16/8/3.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. // 系统宏
  8. #ifndef FWSystemMacro_h
  9. #define FWSystemMacro_h
  10. #import "GlobalVariables.h"
  11. #import "LLFans.h"
  12. // View 圆角
  13. #define ViewRadius(View, Radius)\
  14. \
  15. [View.layer setCornerRadius:(Radius)];\
  16. [View.layer setMasksToBounds:YES]
  17. //#define ASLocalizedString(key) [NSString stringWithFormat:@"%@", [[NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"appLanguage"]] ofType:@"lproj"]] localizedStringForKey:(key) value:nil table:@"ASLocalized"]]
  18. #define KAppLanguage @"appLanguage"
  19. //#define KAppLanguageFirst @"appLanguage_first"
  20. #define IPHONE_X \
  21. ({BOOL isPhoneX = NO;\
  22. if (@available(iOS 11.0, *)) {\
  23. isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0;\
  24. }\
  25. (isPhoneX);})
  26. //根据ip6的屏幕来拉伸
  27. #define kRealValue(with) ((with)*(kScreenW/375.0f))
  28. // 屏幕frame,bounds,size,scale
  29. #define kScreenFrame [UIScreen mainScreen].bounds
  30. #define kScreenBounds [UIScreen mainScreen].bounds
  31. #define kScreenSize [UIScreen mainScreen].bounds.size
  32. #define kScreenScale [UIScreen mainScreen].scale
  33. #define kScreenW [[UIScreen mainScreen] bounds].size.width
  34. #define kScreenH [[UIScreen mainScreen] bounds].size.height
  35. #define kScaleW (kScreenW)*(kScreenScale)
  36. #define kScaleH (kScreenH)*(kScreenScale)
  37. #define KGiftViewHeight kRealValue(358) + MG_BOTTOM_MARGIN
  38. // 屏幕宽度,会根据横竖屏的变化而变化
  39. #define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
  40. // 屏幕高度,会根据横竖屏的变化而变化
  41. #define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
  42. #define kScaleWidth [[UIScreen mainScreen] bounds].size.width/375.00
  43. #define kScaleHeight [[UIScreen mainScreen] bounds].size.height/667.00
  44. // 主窗口的宽、高
  45. #define kMainScreenWidth MainScreenWidth()
  46. #define kMainScreenHeight MainScreenHeight()
  47. static __inline__ CGFloat MainScreenWidth()
  48. {
  49. return UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation) ? [UIScreen mainScreen].bounds.size.width : [UIScreen mainScreen].bounds.size.height;
  50. }
  51. static __inline__ CGFloat MainScreenHeight()
  52. {
  53. return UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation) ? [UIScreen mainScreen].bounds.size.height : [UIScreen mainScreen].bounds.size.width;
  54. }
  55. // 状态栏、导航栏、标签栏高度
  56. #define kStatusBarHeight ([UIApplication sharedApplication].statusBarFrame.size.height)
  57. #define kNavigationBarHeight ([GlobalVariables sharedInstance].appNavigationBarHeight ? : self.navigationController.navigationBar.frame.size.height)
  58. #define kTabBarHeight ([GlobalVariables sharedInstance].appTabBarHeight ? : self.tabBarController.tabBar.frame.size.height)
  59. // 顶部距离
  60. #define MG_TOP_MARGIN (CGFloat)(isIPhoneX() ? 35 : 22)
  61. #define MG_BOTTOM_MARGIN 22
  62. #define MG_BOTTOM_SAFE_HEIGHT (CGFloat)(isIPhoneX() ? 34 : 0)
  63. #define kTopHeight (kStatusBarHeight + kNavigationBarHeight)
  64. #define scale_hight1 kScreenH < 600 ? 50 : 55
  65. #define scale_hight kScreenH > 667 ? 60 : scale_hight1
  66. // 当前所在window
  67. #define kCurrentWindow [AppDelegate sharedAppDelegate].sus_window.rootViewController ? [AppDelegate sharedAppDelegate].sus_window : [AppDelegate sharedAppDelegate].window
  68. //// 当前系统版本号
  69. //#define kCurrentVersionNum [UIDevice currentDevice].systemVersion.doubleValue
  70. #endif /* FWSystemMacro_h */