BRPickerStyle.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. //
  2. // BRPickerStyle.h
  3. // BRPickerViewDemo
  4. //
  5. // Created by renbo on 2019/10/2.
  6. // Copyright © 2019 irenb. All rights reserved.
  7. //
  8. // 最新代码下载地址:https://github.com/91renb/BRPickerView
  9. #import <Foundation/Foundation.h>
  10. #import <UIKit/UIKit.h>
  11. #import "BRPickerViewMacro.h"
  12. NS_ASSUME_NONNULL_BEGIN
  13. // 边框样式(左边取消按钮/右边确定按钮)
  14. typedef NS_ENUM(NSInteger, BRBorderStyle) {
  15. /** 无边框(默认) */
  16. BRBorderStyleNone = 0,
  17. /** 有圆角和边框 */
  18. BRBorderStyleSolid,
  19. /** 仅有圆角 */
  20. BRBorderStyleFill
  21. };
  22. @interface BRPickerStyle : NSObject
  23. /////////////////////////////// 蒙层视图(maskView)///////////////////////////////
  24. /** 设置背景颜色 */
  25. @property (nullable, nonatomic, strong) UIColor *maskColor;
  26. /** 隐藏 maskView,默认为 NO */
  27. @property (nonatomic, assign) BOOL hiddenMaskView;
  28. ////////////////////////////// 弹框视图(alertView)///////////////////////////////
  29. /** 设置 alertView 弹框视图的背景颜色 */
  30. @property (nullable, nonatomic, strong) UIColor *alertViewColor;
  31. /** 设置 alertView 弹框视图左上和右上的圆角半径 */
  32. @property (nonatomic, assign) NSInteger topCornerRadius;
  33. /** 设置 alertView 弹框视图顶部边框线颜色 */
  34. @property (nullable, nonatomic, strong) UIColor *shadowLineColor;
  35. /** 设置 alertView 弹框视图顶部边框线高度 */
  36. @property (nonatomic, assign) CGFloat shadowLineHeight;
  37. /** 隐藏 alertView 弹框视图顶部边框线,默认为 NO */
  38. @property (nonatomic, assign) BOOL hiddenShadowLine;
  39. /** 设置 alertView 弹框视图底部内边距,默认为安全区域底部距屏幕底部的高度 */
  40. @property (nonatomic, assign) CGFloat paddingBottom;
  41. //////////////////////////// 标题栏视图(titleBarView) ////////////////////////////
  42. /** 设置 titleBarView 标题栏的背景颜色 */
  43. @property (nullable, nonatomic, strong) UIColor *titleBarColor;
  44. /** 设置 titleBarView 标题栏的高度 */
  45. @property (nonatomic, assign) CGFloat titleBarHeight;
  46. /** 设置 titleBarView 标题栏底部分割线颜色 */
  47. @property (nullable, nonatomic, strong) UIColor *titleLineColor;
  48. /** 隐藏 titleBarView 标题栏底部分割线,默认为 NO */
  49. @property (nonatomic, assign) BOOL hiddenTitleLine;
  50. /** 隐藏 titleBarView,默认为 NO */
  51. @property (nonatomic, assign) BOOL hiddenTitleBarView;
  52. ////////////////////////// 标题栏中间label(titleLabel)///////////////////////////
  53. /** 设置 titleLabel 的背景颜色 */
  54. @property (nullable, nonatomic, strong) UIColor *titleLabelColor;
  55. /** 设置 titleLabel 文本颜色 */
  56. @property (nullable, nonatomic, strong) UIColor *titleTextColor;
  57. /** 设置 titleLabel 字体大小 */
  58. @property (nullable, nonatomic, strong) UIFont *titleTextFont;
  59. /** 设置 titleLabel 的 frame */
  60. @property (nonatomic, assign) CGRect titleLabelFrame;
  61. /** 隐藏 titleLabel,默认为 NO */
  62. @property (nonatomic, assign) BOOL hiddenTitleLabel;
  63. /////////////////////////////// 取消按钮(cancelBtn)//////////////////////////////
  64. /** 设置 cancelBtn 的背景颜色 */
  65. @property (nullable, nonatomic, strong) UIColor *cancelColor;
  66. /** 设置 cancelBtn 标题的颜色 */
  67. @property (nullable, nonatomic, strong) UIColor *cancelTextColor;
  68. /** 设置 cancelBtn 标题的字体 */
  69. @property (nullable, nonatomic, strong) UIFont *cancelTextFont;
  70. /** 设置 cancelBtn 的 frame */
  71. @property (nonatomic, assign) CGRect cancelBtnFrame;
  72. /** 设置 cancelBtn 的边框样式 */
  73. @property (nonatomic, assign) BRBorderStyle cancelBorderStyle;
  74. /** 设置 cancelBtn 的圆角大小 */
  75. @property (nonatomic, assign) CGFloat cancelCornerRadius;
  76. /** 设置 cancelBtn 的边框宽度 */
  77. @property (nonatomic, assign) CGFloat cancelBorderWidth;
  78. /** 设置 cancelBtn 的 image */
  79. @property (nullable, nonatomic, strong) UIImage *cancelBtnImage;
  80. /** 设置 cancelBtn 的 title */
  81. @property (nullable, nonatomic, copy) NSString *cancelBtnTitle;
  82. /** 隐藏 cancelBtn,默认为 NO */
  83. @property (nonatomic, assign) BOOL hiddenCancelBtn;
  84. /////////////////////////////// 确定按钮(doneBtn)////////////////////////////////
  85. /** 设置 doneBtn 的背景颜色 */
  86. @property (nullable, nonatomic, strong) UIColor *doneColor;
  87. /** 设置 doneBtn 标题的颜色 */
  88. @property (nullable, nonatomic, strong) UIColor *doneTextColor;
  89. /** 设置 doneBtn 标题的字体 */
  90. @property (nullable, nonatomic, strong) UIFont *doneTextFont;
  91. /** 设置 doneBtn 的 frame */
  92. @property (nonatomic, assign) CGRect doneBtnFrame;
  93. /** 设置 doneBtn 的边框样式 */
  94. @property (nonatomic, assign) BRBorderStyle doneBorderStyle;
  95. /** 设置 doneBtn 的圆角大小 */
  96. @property (nonatomic, assign) CGFloat doneCornerRadius;
  97. /** 设置 doneBtn 的边框宽度 */
  98. @property (nonatomic, assign) CGFloat doneBorderWidth;
  99. /** 设置 doneBtn 的 image */
  100. @property (nullable, nonatomic, strong) UIImage *doneBtnImage;
  101. /** 设置 doneBtn 的 title */
  102. @property (nullable, nonatomic, copy) NSString *doneBtnTitle;
  103. /** 隐藏 doneBtn,默认为 NO */
  104. @property (nonatomic, assign) BOOL hiddenDoneBtn;
  105. /////////////////////////////// 选择器(pickerView)///////////////////////////////
  106. /** 设置 picker 的背景颜色 */
  107. @property (nullable, nonatomic, strong) UIColor *pickerColor;
  108. /** 设置 picker 中间两条分割线的背景颜色。暂不支持日期选择器前4种类型 */
  109. @property (nullable, nonatomic, strong) UIColor *separatorColor;
  110. /** 设置 picker 中间两条分割线的高度。暂不支持日期选择器前4种类型 */
  111. @property (nonatomic, assign) CGFloat separatorHeight;
  112. /** 设置 picker 文本的颜色。暂不支持日期选择器前4种类型 */
  113. @property (nullable, nonatomic, strong) UIColor *pickerTextColor;
  114. /** 设置 picker 文本的字体。暂不支持日期选择器前4种类型 */
  115. @property (nullable, nonatomic, strong) UIFont *pickerTextFont;
  116. /** 设置 picker 中间选中行的背景颜色。暂不支持日期选择器前4种类型 */
  117. @property (nullable, nonatomic, strong) UIColor *selectRowColor;
  118. /** 设置 picker 中间选中行文本的颜色。暂不支持日期选择器前4种类型 */
  119. @property (nullable, nonatomic, strong) UIColor *selectRowTextColor;
  120. /** 设置 picker 中间选中行文本的字体。暂不支持日期选择器前4种类型 */
  121. @property (nullable, nonatomic, strong) UIFont *selectRowTextFont;
  122. /** 设置 picker 的高度,系统默认高度为 216 */
  123. @property (nonatomic, assign) CGFloat pickerHeight;
  124. /** 设置 picker 的行高。暂不支持日期选择器前4种类型 */
  125. @property (nonatomic, assign) CGFloat rowHeight;
  126. /**
  127. * 清除iOS14之后选择器默认自带的新样式。暂不支持日期选择器前4种类型
  128. * 主要是:①隐藏中间选择行的背景样式,②清除默认的内边距,③新增中间选择行的两条分割线;与iOS14之前的样式保持一致),默认为 YES
  129. */
  130. @property (nonatomic, assign) BOOL clearPickerNewStyle;
  131. /**
  132. * 设置语言(不设置或为nil时,将随系统的语言自动改变)
  133. * language: zh-Hans(简体中文)、zh-Hant(繁体中文)、en(英语 )
  134. */
  135. @property(nullable, nonatomic, copy) NSString *language;
  136. /////// 日期选择器单位样式(showUnitType == BRShowUnitTypeOnlyCenter 时生效。暂不支持日期选择器前4种类型 )///////
  137. /** 设置日期选择器单位文本的颜色 */
  138. @property (nullable, nonatomic, strong) UIColor *dateUnitTextColor;
  139. /** 设置日期选择器单位文本的字体 */
  140. @property (nullable, nonatomic, strong) UIFont *dateUnitTextFont;
  141. /** 设置日期选择器单位 label 的水平方向偏移量 */
  142. @property (nonatomic, assign) CGFloat dateUnitOffsetX;
  143. /** 设置日期选择器单位 label 的竖直方向偏移量 */
  144. @property (nonatomic, assign) CGFloat dateUnitOffsetY;
  145. //////////////////////////////// 常用的几种模板样式 ////////////////////////////////
  146. /// 弹框模板样式1 - 取消/确定按钮圆角样式
  147. /// @param themeColor 主题颜色
  148. + (instancetype)pickerStyleWithThemeColor:(nullable UIColor *)themeColor;
  149. /// 弹框模板样式2 - 顶部圆角样式 + 完成按钮
  150. /// @param doneTextColor 完成按钮标题的颜色
  151. + (instancetype)pickerStyleWithDoneTextColor:(nullable UIColor *)doneTextColor;
  152. /// 弹框模板样式3 - 顶部圆角样式 + 图标按钮
  153. /// @param doneBtnImage 完成按钮的 image
  154. + (instancetype)pickerStyleWithDoneBtnImage:(nullable UIImage *)doneBtnImage;
  155. /** 设置选择器中间选中行的样式(组件内部使用)*/
  156. - (void)setupPickerSelectRowStyle:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
  157. /** 添加选择器中间行上下两条分割线(iOS14之后系统默认去掉,需要手动添加;组件内部使用)*/
  158. - (void)addSeparatorLineView:(UIView *)pickerView;
  159. @end
  160. NS_ASSUME_NONNULL_END