UIButton+RQExtension.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // UIButton+RQExtension.h
  3. // XinShouJiaDao
  4. //
  5. // Created by 张嵘 on 2021/7/7.
  6. // Copyright © 2021 JCZ. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. // 定义一个枚举(包含了四种类型的button)
  11. typedef NS_ENUM(NSUInteger, RQButtonEdgeInsetsStyle) {
  12. RQButtonEdgeInsetsStyleTop, // image在上,label在下
  13. RQButtonEdgeInsetsStyleLeft, // image在左,label在右
  14. RQButtonEdgeInsetsStyleBottom, // image在下,label在上
  15. RQButtonEdgeInsetsStyleRight // image在右,label在左
  16. };
  17. @interface UIButton (RQExtension)
  18. /**默认的字体大小
  19. */
  20. - (void)setImage:(UIImage *)image withTitle:(NSString *)title forState:(UIControlState)stateType;
  21. - (void)setImage:(UIImage *)image withTitle:(NSString *)title Font:(CGFloat)font forState:(UIControlState)stateType;
  22. - (void)setTitle:(NSString*)title textColor:(UIColor*)color Font:(CGFloat)font fotState:(UIControlState)stateType;
  23. - (void)setImage:(UIImage *)image withTitle:(NSString*)title textColor:(UIColor*)color Font:(CGFloat)font fotState:(UIControlState)stateType;
  24. /**简化按钮事件添加。要求一定要实现btnClick;
  25. */
  26. -(void)target:(id)obj;
  27. -(void)target:(id)obj tag:(NSInteger)tag;
  28. -(void)setTitleNormal:(NSString*)title;
  29. -(void)setTitleSelect:(NSString*)title;
  30. /**
  31. * 设置button的titleLabel和imageView的布局样式,及间距
  32. *
  33. * @param style titleLabel和imageView的布局样式
  34. * @param space titleLabel和imageView的间距
  35. */
  36. - (void)layoutButtonWithEdgeInsetsStyle:(RQButtonEdgeInsetsStyle)style
  37. imageTitleSpace:(CGFloat)space;
  38. @end
  39. NS_ASSUME_NONNULL_END