ASEnterItemV.m 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // ASEnterItemV.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2023/5/15.
  6. //
  7. #import "ASEnterItemV.h"
  8. @implementation ASEnterItemV
  9. - (void)setData:(NSString *)title icon:(UIImage *)img {
  10. self.imageV.image = img;
  11. self.titleLb.text = title;
  12. }
  13. - (instancetype)initWithFrame:(CGRect)frame {
  14. self = [super initWithFrame:frame];
  15. if (self) {
  16. [self configSubV];
  17. }
  18. return self;
  19. }
  20. - (void)configSubV {
  21. [self addSubview:self.imageV];
  22. [self addSubview:self.titleLb];
  23. [self addSubview:self.btn];
  24. [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  25. make.left.equalTo(self).offset(5);
  26. make.right.equalTo(self).offset(-5);
  27. make.bottom.equalTo(self).offset(-5);
  28. make.height.equalTo(@14);
  29. }];
  30. [self.imageV mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.centerX.equalTo(self.titleLb);
  32. make.top.equalTo(self).offset(5);
  33. make.bottom.equalTo(self.titleLb.mas_top).offset(-10);
  34. }];
  35. [self.btn mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.edges.equalTo(self);
  37. }];
  38. }
  39. -(void)btnAction {
  40. if (self.clickCallBack) {
  41. self.clickCallBack();
  42. }
  43. }
  44. -(UIButton *)btn {
  45. if (!_btn) {
  46. _btn = [UIButton buttonWithType:UIButtonTypeCustom];
  47. [_btn addTarget:self action:@selector(btnAction) forControlEvents:UIControlEventTouchUpInside];
  48. }
  49. return _btn;
  50. }
  51. - (UIImageView *)imageV {
  52. if (!_imageV) {
  53. UIImageView *imgV = [[UIImageView alloc] init];
  54. imgV.contentMode = UIViewContentModeScaleAspectFit;
  55. _imageV = imgV;
  56. }
  57. return _imageV;
  58. }
  59. - (UILabel *)titleLb {
  60. if (!_titleLb) {
  61. UILabel *lb = [[UILabel alloc] init];
  62. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  63. lb.textColor = UIColor.blackColor;
  64. lb.textAlignment = NSTextAlignmentCenter;
  65. _titleLb = lb;
  66. }
  67. return _titleLb;
  68. }
  69. @end