ASMyCartNoDataView.m 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // ASMyCartNoDataView.m
  3. // Asteria
  4. //
  5. // Created by xingyu on 2024/5/23.
  6. //
  7. #import "ASMyCartNoDataView.h"
  8. @interface ASMyCartNoDataView()
  9. @property (nonatomic, strong) UIView *emptyV;
  10. @property (nonatomic, strong) UIImageView *emptyImageView;
  11. @end
  12. @implementation ASMyCartNoDataView
  13. - (instancetype)initWithFrame:(CGRect)frame {
  14. if (self = [super initWithFrame:frame]) {
  15. [self addSubview:self.emptyV];
  16. [self.emptyV mas_makeConstraints:^(MASConstraintMaker *make) {
  17. make.edges.mas_equalTo(0);
  18. }];
  19. _emptyImageView = [[UIImageView alloc] init];
  20. _emptyImageView.contentMode = UIViewContentModeScaleAspectFit;
  21. _emptyImageView.image = [UIImage imageNamed:@"cart_no_data"];
  22. [self.emptyV addSubview:_emptyImageView];
  23. [_emptyImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  24. make.centerX.equalTo(self.emptyV);
  25. make.top.mas_equalTo(60);
  26. make.width.height.mas_equalTo(KScreenWidth - 80);
  27. }];
  28. K_WEAK_SELF;
  29. dispatch_async(dispatch_get_main_queue(), ^{
  30. K_STRONG_SELF;
  31. [UIView viewAddHorColorBg:self.emptyV colorArr:@[
  32. (id)_E0FFF5.CGColor,
  33. (id)Col_FFF.CGColor
  34. ] startP:CGPointMake(0.5, 0.25) endP:CGPointMake(0.5, 1)];
  35. [self.emptyV bringSubviewToFront:self.emptyImageView];
  36. });
  37. UIButton *clickBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  38. clickBtn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:14];
  39. [clickBtn setTitle:@"BACK TO PREVIOUS PAGE" forState:UIControlStateNormal];
  40. clickBtn.backgroundColor = Col_000;
  41. [clickBtn addTarget:self action:@selector(_btnClick) forControlEvents:UIControlEventTouchUpInside];
  42. TT_ViewRadius(clickBtn, 4);
  43. [clickBtn setTitleColor:Col_FFF forState:UIControlStateNormal];
  44. [self addSubview:clickBtn];
  45. [clickBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.top.mas_equalTo(_emptyImageView.mas_bottom).offset(48);
  47. make.height.mas_equalTo(45);
  48. make.left.mas_equalTo(40);
  49. make.right.mas_equalTo(-40);
  50. }];
  51. }
  52. return self;
  53. }
  54. - (void)_btnClick {
  55. [Fuction_Tool popToHomeVc];
  56. }
  57. - (UIView *)emptyV {
  58. if (!_emptyV) {
  59. UIView *v = [UIView baseV];
  60. v.backgroundColor = Col_FFF;
  61. _emptyV = v;
  62. }
  63. return _emptyV;
  64. }
  65. @end