HJBlankView.m 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //
  2. // HJBlankView.m
  3. // HappyJob
  4. //
  5. // Created by Bob on 2019/5/21.
  6. // Copyright © 2019 Bob. All rights reserved.
  7. //
  8. #import "HJBlankView.h"
  9. @interface HJBlankView ()
  10. @property (nonatomic, strong) UIView *canvasView;
  11. @end
  12. @implementation HJBlankView
  13. - (instancetype)init {
  14. if (self = [super init])
  15. {
  16. // self.backgroundColor = [UIColor redColor];
  17. [self addSubview:self.canvasView];
  18. [self.canvasView addSubview:self.imageView];
  19. [self.canvasView addSubview:self.titleLabel];
  20. [self.canvasView addSubview:self.detailLabel];
  21. [self makeConstraints];
  22. }
  23. return self;
  24. }
  25. - (void)makeConstraints {
  26. [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
  27. make.top.centerX.equalTo(self.canvasView);
  28. }];
  29. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.centerX.equalTo(self.canvasView);
  31. make.top.equalTo(self.imageView.mas_bottom).offset(45);
  32. }];
  33. [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.top.equalTo(self.titleLabel.mas_bottom).with.offset(10);
  35. make.centerX.equalTo(self.canvasView);
  36. }];
  37. [self.canvasView mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.top.equalTo(self.imageView);
  39. make.left.right.bottom.equalTo(self.detailLabel);
  40. make.center.equalTo(self);
  41. }];
  42. }
  43. #pragma mark - getters and setters
  44. - (UIView *)canvasView {
  45. if (_canvasView == nil)
  46. {
  47. _canvasView = [[UIView alloc] init];
  48. // _canvasView.backgroundColor = [UIColor yellowColor];
  49. }
  50. return _canvasView;
  51. }
  52. - (UIImageView *)imageView {
  53. if (_imageView == nil)
  54. {
  55. _imageView = [[UIImageView alloc] init];
  56. _imageView.image = [UIImage imageNamed:@"blank_pages_icon"];
  57. }
  58. return _imageView;
  59. }
  60. - (UILabel *)titleLabel {
  61. if (_titleLabel == nil)
  62. {
  63. _titleLabel = [[UILabel alloc]init];
  64. _titleLabel.text = @"空空如也";
  65. _titleLabel.textColor = COLOR_BACK_31;
  66. _titleLabel.font = [UIFont boldSystemFontOfSize:21];
  67. _titleLabel.textAlignment = NSTextAlignmentCenter;
  68. }
  69. return _titleLabel;
  70. }
  71. - (UILabel *)detailLabel {
  72. if (_detailLabel == nil)
  73. {
  74. _detailLabel = [[UILabel alloc] init];
  75. _detailLabel.textColor = COLOR_GRAY_88;
  76. _detailLabel.text = @"您目前没有正在进行中的订单";
  77. _detailLabel.font = [UIFont systemFontOfSize:16];
  78. _detailLabel.textAlignment = NSTextAlignmentCenter;
  79. _detailLabel.numberOfLines = 0;
  80. }
  81. return _detailLabel;
  82. }
  83. @end