口袋优选

KBNoDataView.m 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // KBNoDataView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/6/11.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBNoDataView.h"
  9. @implementation KBNoDataView
  10. - (instancetype)initWithFrame:(CGRect)frame {
  11. self = [super initWithFrame:frame];
  12. if (self) {
  13. self.backgroundColor = [UIColor whiteColor];
  14. [self initSubviews];
  15. }
  16. return self;
  17. }
  18. - (void)initSubviews {
  19. UIImageView *topImageView = [[UIImageView alloc] init];
  20. topImageView.backgroundColor = [UIColor clearColor];
  21. topImageView.image = [UIImage imageNamed:@"search_no_data"];
  22. [self addSubview:topImageView];
  23. UILabel *topLabel = [[UILabel alloc] init];
  24. topLabel.backgroundColor = [UIColor clearColor];
  25. topLabel.textColor = [UIColor YHColorWithHex:0x333333];
  26. topLabel.font = [UIFont systemFontOfSize:FITSIZE(14)];
  27. topLabel.text = @"没有找到浏览过的商品";
  28. [self addSubview:topLabel];
  29. UILabel *middleLabel = [[UILabel alloc] init];
  30. middleLabel.backgroundColor = [UIColor clearColor];
  31. middleLabel.textColor = [UIColor YHColorWithHex:0x888888];
  32. middleLabel.font = [UIFont systemFontOfSize:FITSIZE(14)];
  33. middleLabel.text = @"赶快去逛逛吧";
  34. [self addSubview:middleLabel];
  35. UIButton *bottomButton = [UIButton buttonWithType:UIButtonTypeCustom];
  36. bottomButton.backgroundColor = [UIColor clearColor];
  37. [bottomButton setTitleColor:[UIColor YHColorWithHex:0x666666] forState:UIControlStateNormal];
  38. bottomButton.titleLabel.font = [UIFont systemFontOfSize:FITSIZE(15)];
  39. [bottomButton setTitle:@"刷新" forState:UIControlStateNormal];
  40. bottomButton.layer.borderWidth = 1.0f;
  41. bottomButton.layer.borderColor = [UIColor YHColorWithHex:0xb3b3b3].CGColor;
  42. bottomButton.layer.cornerRadius = 3.0f;
  43. [bottomButton addTarget:self action:@selector(refreshButtonAction) forControlEvents:UIControlEventTouchUpInside];
  44. [self addSubview:bottomButton];
  45. [topImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.centerX.equalTo(self);
  47. make.top.equalTo(self).offset(FITSIZE(30));
  48. }];
  49. [topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.centerX.equalTo(self);
  51. make.top.equalTo(topImageView.mas_bottom).offset(FITSIZE(22));
  52. }];
  53. [middleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.centerX.equalTo(self);
  55. make.top.equalTo(topLabel.mas_bottom).offset(FITSIZE(6));
  56. }];
  57. [bottomButton mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.centerX.equalTo(self);
  59. make.top.equalTo(middleLabel.mas_bottom).offset(FITSIZE(20));
  60. make.width.mas_equalTo(FITSIZE(102));
  61. make.height.mas_equalTo(FITSIZE(30));
  62. }];
  63. }
  64. - (void)refreshButtonAction {
  65. if (self.refreshClick) {
  66. self.refreshClick();
  67. }
  68. }
  69. @end