UIBarButtonItem+RQExtension.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // UIBarButtonItem+RQExtension.h
  3. // RQCommon
  4. //
  5. // Created by 张嵘 on 2018/11/16.
  6. // Copyright © 2018 张嵘. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. /// 获取系统颜色
  10. static inline UIColor *RQBarButtonItemTitleColor(BOOL useSystem) {
  11. return useSystem ? RQ_MAIN_TEXT_COLOR_2 : RQ_MAIN_TEXT_COLOR_2;
  12. }
  13. @interface UIBarButtonItem (RQExtension)
  14. /**
  15. 通过系统的方法,初始化一个UIBarButtonItem
  16. @param title 显示的文字,例如'完成'、'取消'
  17. @param titleColor title的颜色,if nil ,The Color is [UIColor whiteColor]
  18. @param imageName 图片名称
  19. @param target target
  20. @param selector selector
  21. @param textType 是否是纯文字
  22. @return init a UIBarButtonItem
  23. */
  24. + (UIBarButtonItem *)rq_systemItemWithTitle:(NSString *)title
  25. titleColor:(UIColor *)titleColor
  26. imageName:(NSString *)imageName
  27. target:(id)target
  28. selector:(SEL)selector
  29. textType:(BOOL)textType;
  30. /**
  31. 通过自定义的方法,快速初始化一个UIBarButtonItem,内部是按钮
  32. @param title 显示的文字,例如'完成'、'取消'
  33. @param font 文字的字体
  34. @param titleColor title的颜色,if nil ,The Color is [UIColor whiteColor]
  35. @param imageName 图片名称
  36. @param target target
  37. @param selector selector
  38. @param contentHorizontalAlignment 文本对齐方向
  39. @param edgeInsetsStyle titleLabel和imageView的布局样式
  40. @param space 文字图片间距
  41. @return UIBarButtonItem
  42. */
  43. + (UIBarButtonItem *)rq_customItemWithTitle:(NSString *)title
  44. font:(UIFont *)font
  45. titleColor:(UIColor *)titleColor
  46. imageName:(NSString *)imageName
  47. target:(id)target
  48. selector:(SEL)selector
  49. contentHorizontalAlignment:(UIControlContentHorizontalAlignment)contentHorizontalAlignment
  50. EdgeInsetsStyle:(RQButtonEdgeInsetsStyle)edgeInsetsStyle
  51. space:(CGFloat)space;
  52. /**
  53. 快速创建一个导航栏leftBarButtonItem 用于返回(pop)或者(dismiss),切记只能是纯图片 (eg: < or X)
  54. 且可以加大点击范围
  55. @param title title
  56. @param imageName 返回按钮的图片
  57. @param target target
  58. @param action action
  59. @return UIBarButtonItem Instance
  60. */
  61. + (UIBarButtonItem *)rq_backItemWithTitle:(NSString *)title
  62. imageName:(NSString *)imageName
  63. target:(id)target
  64. action:(SEL)action;
  65. @end