UIFont+RQExtension.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. //
  2. // UIFont+RQExtension.h
  3. // RQCommon
  4. //
  5. // Created by 张嵘 on 2018/11/16.
  6. // Copyright © 2018 张嵘. All rights reserved.
  7. //
  8. /**
  9. * 但是苹方字体 iOS9.0+出现 需要做适配
  10. * 这个分类主要用来 字体...
  11. (
  12. "PingFangSC-Ultralight",
  13. "PingFangSC-Regular",
  14. "PingFangSC-Semibold",
  15. "PingFangSC-Thin",
  16. "PingFangSC-Light",
  17. "PingFangSC-Medium"
  18. )
  19. */
  20. // IOS版本
  21. #define RQIOSVersion ([[[UIDevice currentDevice] systemVersion] floatValue])
  22. /// 设置系统的字体大小(YES:粗体 NO:常规)
  23. #define RQFont(__size__,__bold__) ((__bold__)?([UIFont boldSystemFontOfSize:__size__]):([UIFont systemFontOfSize:__size__]))
  24. /// 极细体
  25. #define RQUltralightFont(__size__) ((RQIOSVersion<9.0)?RQFont(__size__ , YES):[UIFont rq_fontForPingFangSC_UltralightFontOfSize:__size__])
  26. /// 纤细体
  27. #define RQThinFont(__size__) ((RQIOSVersion<9.0)?RQFont(__size__ , YES):[UIFont rq_fontForPingFangSC_ThinFontOfSize:__size__])
  28. /// 细体
  29. #define RQLightFont(__size__) ((RQIOSVersion<9.0)?RQFont(__size__ , YES):[UIFont rq_fontForPingFangSC_LightFontOfSize:__size__])
  30. // 中等
  31. #define RQMediumFont(__size__) ((RQIOSVersion<9.0)?RQFont(__size__ , YES):[UIFont rq_fontForPingFangSC_MediumFontOfSize:__size__])
  32. // 常规
  33. #define RQRegularFont(__size__) ((RQIOSVersion<9.0)?RQFont(__size__ , NO):[UIFont rq_fontForPingFangSC_RegularFontOfSize:__size__])
  34. /** 中粗体 */
  35. #define RQSemiboldFont(__size__) ((RQIOSVersion<9.0)?RQFont(__size__ , YES):[UIFont rq_fontForPingFangSC_SemiboldFontOfSize:__size__])
  36. /// 苹方常规字体 10
  37. #define RQRegularFont_10 RQRegularFont(10.0f)
  38. /// 苹方常规字体 11
  39. #define RQRegularFont_11 RQRegularFont(11.0f)
  40. /// 苹方常规字体 12
  41. #define RQRegularFont_12 RQRegularFont(12.0f)
  42. /// 苹方常规字体 13
  43. #define RQRegularFont_13 RQRegularFont(13.0f)
  44. /** 苹方常规字体 14 */
  45. #define RQRegularFont_14 RQRegularFont(14.0f)
  46. /// 苹方常规字体 15
  47. #define RQRegularFont_15 RQRegularFont(15.0f)
  48. /// 苹方常规字体 16
  49. #define RQRegularFont_16 RQRegularFont(16.0f)
  50. /// 苹方常规字体 17
  51. #define RQRegularFont_17 RQRegularFont(17.0f)
  52. /// 苹方常规字体 18
  53. #define RQRegularFont_18 RQRegularFont(18.0f)
  54. /// 苹方常规字体 19
  55. #define RQRegularFont_19 RQRegularFont(19.0f)
  56. /// 苹方常规字体 20
  57. #define RQRegularFont_20 RQRegularFont(20.0f)
  58. #import <UIKit/UIKit.h>
  59. @interface UIFont (RQExtension)
  60. /**
  61. * 苹方极细体
  62. *
  63. * @param fontSize 字体大小
  64. *
  65. */
  66. + (instancetype)rq_fontForPingFangSC_UltralightFontOfSize:(CGFloat)fontSize;
  67. /**
  68. * 苹方常规体
  69. *
  70. * @param fontSize 字体大小
  71. *
  72. */
  73. + (instancetype)rq_fontForPingFangSC_RegularFontOfSize:(CGFloat)fontSize;
  74. /**
  75. * 苹方中粗体
  76. *
  77. * @param fontSize 字体大小
  78. *
  79. */
  80. + (instancetype)rq_fontForPingFangSC_SemiboldFontOfSize:(CGFloat)fontSize;
  81. /**
  82. * 苹方纤细体
  83. *
  84. * @param fontSize 字体大小
  85. *
  86. */
  87. + (instancetype)rq_fontForPingFangSC_ThinFontOfSize:(CGFloat)fontSize;
  88. /**
  89. * 苹方细体
  90. *
  91. * @param fontSize 字体大小
  92. *
  93. */
  94. + (instancetype)rq_fontForPingFangSC_LightFontOfSize:(CGFloat)fontSize;
  95. /**
  96. * 苹方中黑体
  97. *
  98. * @param fontSize 字体大小
  99. *
  100. */
  101. + (instancetype)rq_fontForPingFangSC_MediumFontOfSize:(CGFloat)fontSize;
  102. @end