TDSCommonUIHelper.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // TDSCommonUIHelper.h
  3. // TDSCommon
  4. //
  5. // Created by Bottle K on 2021/3/2.
  6. //
  7. #import <Foundation/Foundation.h>
  8. #import <UIKit/UIKit.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. @interface TDSCommonUIHelper : NSObject
  11. /// 从common bundle获取image
  12. + (UIImage *)getImageFromCommonWithImageName:(NSString *)name;
  13. /// 从bundle获取image
  14. + (UIImage *)getImageFromBundle:(NSString *)bundleName withImage:(NSString *)imageName;
  15. /// 从bundle获取翻译后的文案
  16. + (NSString *)getTranslatedStringFromCommonWithKey:(NSString *)key;
  17. /// rgb转color
  18. + (UIColor *)rgbToColorWithRed:(CGFloat)red
  19. green:(CGFloat)green
  20. blue:(CGFloat)blue;
  21. /// rgba转color
  22. + (UIColor *)rgbToColorWithRed:(CGFloat)red
  23. green:(CGFloat)green
  24. blue:(CGFloat)blue
  25. aplha:(CGFloat)alpha;
  26. /// hex转color
  27. + (UIColor *)hexToColor:(int)hexValue;
  28. /// hex转color
  29. + (UIColor *)hexToColor:(int)hexValue alpha:(CGFloat)alpha;
  30. /// 屏幕宽度,会根据横竖屏的变化而变化
  31. + (CGFloat)screenWidth;
  32. /// 屏幕高度,会根据横竖屏的变化而变化
  33. + (CGFloat)screenHeight;
  34. /// 屏幕宽度,跟横竖屏无关
  35. + (CGFloat)deviceWidth;
  36. /// 屏幕高度,跟横竖屏无关
  37. + (CGFloat)deviceHeight;
  38. /// 用户界面横屏了才会返回YES
  39. + (BOOL)isUILandscape;
  40. /// 无论支不支持横屏,只要设备横屏了,就会返回YES
  41. + (BOOL)isDeviceLandscape;
  42. /// 是否有刘海
  43. + (BOOL)hasNotch;
  44. /// 安全区域(上左下右)
  45. + (UIEdgeInsets)safeAreaInsets;
  46. + (UIViewController *)findTopViewController;
  47. + (UIViewController *)findUIViewController:(UIViewController *)controller;
  48. @end
  49. NS_ASSUME_NONNULL_END