RABadgeButton.m 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // RABadgeButton.m
  3. // Apex And Drivers
  4. //
  5. // Created by Jack on 2018/11/2.
  6. // Copyright © 2018年 USAI. All rights reserved.
  7. //
  8. #import "RABadgeButton.h"
  9. @interface RABadgeButton ()
  10. @property (nonatomic,strong) IBOutlet UILabel *numberLabel;
  11. @property (nonatomic,strong) IBOutlet UIButton *itemButton;
  12. @end
  13. @implementation RABadgeButton
  14. + (instancetype)badgeButton {
  15. RABadgeButton *btn = [[[NSBundle mainBundle] loadNibNamed:@"badge_button" owner:nil options:nil] objectAtIndex:0];
  16. return btn;
  17. }
  18. - (void)awakeFromNib {
  19. [super awakeFromNib];
  20. self.numberLabel.text = nil;
  21. self.numberLabel.backgroundColor = UIColorFromRGB(0x299D4D);
  22. self.numberLabel.layer.cornerRadius = 7.5f;
  23. self.numberLabel.layer.masksToBounds = YES;
  24. }
  25. - (void)setImage:(UIImage *)image forState:(UIControlState)state {
  26. [self.itemButton setImage:image forState:state];
  27. }
  28. - (void)setTintColor:(UIColor *)tintColor {
  29. [self.itemButton setTintColor:tintColor];
  30. }
  31. - (void)setNumber:(NSUInteger)number {
  32. self.numberLabel.text = [NSString stringWithFormat:@"%lu",(unsigned long)number];
  33. }
  34. - (void)setNumberColor:(UIColor *)color {
  35. self.numberLabel.textColor = color;
  36. }
  37. - (void)setNumberBackgroundColor:(UIColor *)color {
  38. self.numberLabel.backgroundColor = color;
  39. }
  40. - (IBAction)itemButtonClick:(id)sender {
  41. }
  42. @end