HomeActionView.m 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // HomeActionView.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by 王智 on 2022/7/7.
  6. //
  7. #import "HomeActionView.h"
  8. @interface HomeActionView ()
  9. @property (weak, nonatomic) IBOutlet UILabel *actionNameLabel;
  10. @property (weak, nonatomic) IBOutlet UIImageView *actionImage;
  11. @property (weak, nonatomic) IBOutlet UIButton *actionButton;
  12. @property (nonatomic, copy) HomeActionCallback callback;
  13. @end
  14. @implementation HomeActionView
  15. + (instancetype)shareInstance {
  16. HomeActionView *view = [[[NSBundle mainBundle] loadNibNamed:@"HomeActionView" owner:nil options:nil] firstObject];
  17. return view;
  18. }
  19. - (void)configWithName:(NSString *)actionName firstDesc:(NSString *)firstDesc imageName:(NSString *)actionImage index:(NSInteger)actionIndex callback:(HomeActionCallback)callback {
  20. if (callback) {
  21. self.callback = callback;
  22. }
  23. self.actionNameLabel.text = actionName;
  24. self.firstDescLabel.text = firstDesc;
  25. self.actionButton.tag = actionIndex;
  26. [self.actionImage setImage:[UIImage imageNamed:actionImage]];
  27. }
  28. - (IBAction)buttonAction:(UIButton *)sender {
  29. if (self.callback) {
  30. self.callback(sender.tag);
  31. }
  32. }
  33. /*
  34. // Only override drawRect: if you perform custom drawing.
  35. // An empty implementation adversely affects performance during animation.
  36. - (void)drawRect:(CGRect)rect {
  37. // Drawing code
  38. }
  39. */
  40. @end