説明なし

FKBasketEmptyView.m 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // FKBasketEmptyView.m
  3. // FirstLink
  4. //
  5. // Created by jack on 16/2/24.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKBasketEmptyView.h"
  9. @implementation FKBasketEmptyView
  10. - (instancetype)initWithFrame:(CGRect)frame{
  11. if (self = [super initWithFrame:frame]) {
  12. [self addAllSubviews];
  13. self.backgroundColor = UIColorFromRGB(0xf5f5f5);
  14. }
  15. return self;
  16. }
  17. - (void)addAllSubviews{
  18. UIImageView *basketImgView = ({
  19. UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"basket_empty"]];
  20. [imageView setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
  21. imageView;
  22. });
  23. UILabel *titleLabel = ({
  24. UILabel *label = [[UILabel alloc]init];
  25. label.text = @"“购物车空空如也”";
  26. label.font = [UIFont systemFontOfSize:15];
  27. label.textColor = UIColorFromRGB(0x999999);
  28. [label setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
  29. label;
  30. });
  31. [self addSubview:basketImgView];
  32. [self addSubview:titleLabel];
  33. [self addSubview:self.goAroundBtn];
  34. [basketImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.top.equalTo(self).offset(90);
  36. make.centerX.equalTo(self);
  37. }];
  38. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.top.equalTo(basketImgView.mas_bottom).offset(15);
  40. make.centerX.equalTo(self);
  41. }];
  42. [self.goAroundBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.top.equalTo(titleLabel.mas_bottom).offset(70);
  44. make.centerX.equalTo(self);
  45. make.size.mas_equalTo(CGSizeMake(150, 35));
  46. }];
  47. }
  48. - (UIButton *)goAroundBtn{
  49. if (_goAroundBtn == nil) {
  50. _goAroundBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  51. [_goAroundBtn setTitle:@"去逛逛" forState:UIControlStateNormal];
  52. [_goAroundBtn setTitleColor:UIColorFromRGB(0x666666) forState:UIControlStateNormal];
  53. _goAroundBtn.titleLabel.font = [UIFont systemFontOfSize:15];
  54. _goAroundBtn.backgroundColor = [UIColor whiteColor];
  55. _goAroundBtn.layer.cornerRadius = 5;
  56. _goAroundBtn.layer.borderColor = [UIColorFromRGB(0xcccccc) CGColor];
  57. _goAroundBtn.layer.borderWidth = 0.5f;
  58. }
  59. return _goAroundBtn;
  60. }
  61. @end