YMChoiceButton.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // YMChoiceButton.h
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2022/9/20.
  6. //
  7. #import <UIKit/UIKit.h>
  8. NS_ASSUME_NONNULL_BEGIN
  9. @class YMChoiceButton;
  10. @protocol YMChoiceButtonDelegate;
  11. typedef NS_ENUM(NSInteger, YMChoiceButtonStatusType) {
  12. YMChoiceButtonStatusTypeCancel = 0,
  13. YMChoiceButtonStatusTypeSelect = 1,
  14. };
  15. typedef NS_ENUM(NSInteger, YMChoiceButtonClickStateType) {
  16. YMChoiceButtonNoClickableState = 0,
  17. YMChoiceButtonClickableState = 1,
  18. };
  19. typedef NS_ENUM(NSInteger, YMChoiceType) {
  20. YMChoiceTypeRadio = 0,
  21. YMChoiceTypeCheck = 1,
  22. };
  23. @protocol YMChoiceButtonDelegate <NSObject>
  24. @required
  25. -(void)ym_choiceButtonSelectedAtIndex:(NSUInteger)index inGroup:(NSString*)groupId;
  26. -(void)ym_choiceButtonCancelAtIndex:(NSUInteger)index inGroup:(NSString*)groupId;
  27. @end
  28. @interface YMChoiceButton: UIButton
  29. {
  30. NSString *_groupId;
  31. NSUInteger _index;
  32. YMChoiceButtonStatusType _statustype;
  33. YMChoiceType _choiceType;
  34. }
  35. @property (nonatomic, readonly) NSString* groupId;
  36. @property (nonatomic, readonly) YMChoiceType choiceType;
  37. @property (nonatomic, assign, readwrite) id<YMChoiceButtonDelegate> delegate;
  38. @property (nonatomic, assign, readwrite) YMChoiceButtonStatusType statusType;
  39. //仅仅是对ChoiceTypeRadio状态下面有效
  40. @property (nonatomic, assign, readwrite) BOOL mustChooseOne;
  41. @property (nonatomic, assign, readwrite) NSUInteger index;
  42. + (id)buttonWithFrame:(CGRect)frame andChoiceType:(YMChoiceType)choiceType withIndex:(NSUInteger)index inGroup:(NSString*)groupId withSelectedImage:(UIImage*)selectedImage andNormalImage:(UIImage*)normalImage;
  43. @end
  44. NS_ASSUME_NONNULL_END