GuiZuView.m 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. //
  2. // GuiZuView.m
  3. // BuguLive
  4. //
  5. // Created by bugu on 2019/12/2.
  6. // Copyright © 2019 xfg. All rights reserved.
  7. //
  8. #import "GuiZuView.h"
  9. #import "GuiZuRightsCollectCell.h"
  10. @interface GuiZuView ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
  11. @property(nonatomic, strong) UIImageView *bgImageView;
  12. @property(nonatomic, strong) UIImageView *iconImageView;
  13. @property(nonatomic, strong) UIView *gzView;
  14. @property(nonatomic, strong) UILabel *nameLabel;
  15. @property(nonatomic, strong) UILabel *descLabel;
  16. @property (nonatomic, retain) UICollectionView *collectionView;
  17. @end
  18. static NSString *const image_name_bg = @"贵族背景";
  19. static NSString *const image_name = @"玄铁";
  20. @implementation GuiZuView
  21. - (instancetype)initWithFrame:(CGRect)frame
  22. {
  23. self = [super initWithFrame:frame];
  24. if (self) {
  25. [self initUI];
  26. }
  27. return self;
  28. }
  29. - (void)initUI{
  30. _bgImageView = ({
  31. UIImageView *imageView = [[UIImageView alloc] init];
  32. imageView.image = [UIImage imageNamed:image_name_bg];
  33. imageView;
  34. });
  35. _iconImageView = ({
  36. UIImageView *imageView = [[UIImageView alloc] init];
  37. imageView.image = [UIImage imageNamed:image_name];
  38. imageView;
  39. });
  40. [self addSubview:_bgImageView];
  41. [self addSubview:_iconImageView];
  42. _gzView = ({
  43. UIView * view = [[UIView alloc]init];
  44. view.backgroundColor = kWhiteColor;
  45. view.layer.cornerRadius = 8;
  46. view.layer.shadowColor = [UIColor colorWithRed:207/255.0 green:207/255.0 blue:207/255.0 alpha:0.5].CGColor;
  47. view.layer.shadowOffset = CGSizeMake(0,2);
  48. view.layer.shadowOpacity = 1;
  49. view.layer.shadowRadius = 7;
  50. view;
  51. });
  52. _nameLabel = ({
  53. UILabel * label = [[UILabel alloc]init];
  54. label.textColor = [UIColor colorWithHexString:@"#333333"];
  55. label.font = [UIFont systemFontOfSize:18];
  56. label.text = ASLocalizedString(@"贵族特权");
  57. label;
  58. });
  59. _descLabel = ({
  60. UILabel * label = [[UILabel alloc]init];
  61. label.textColor = [UIColor colorWithHexString:@"#666666"];
  62. label.font = [UIFont systemFontOfSize:14];
  63. label.text = ASLocalizedString(@"拥有特权2/9");
  64. label;
  65. });
  66. [self addSubview:_gzView];
  67. [_gzView addSubview:_nameLabel];
  68. [_gzView addSubview:_descLabel];
  69. [_gzView addSubview:self.collectionView];
  70. }
  71. - (void)layoutSubviews {
  72. [super layoutSubviews];
  73. [_bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.top.left.right.mas_equalTo(0);
  75. make.height.mas_equalTo(kRealValue(255));
  76. }];
  77. [_iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.top.mas_equalTo(58);
  79. make.centerX.mas_equalTo(0);
  80. }];
  81. [_gzView mas_makeConstraints:^(MASConstraintMaker *make) {
  82. make.top.equalTo(_iconImageView.mas_bottom).offset(36);
  83. make.left.mas_equalTo(10);
  84. make.centerX.mas_equalTo(0);
  85. // make.height.mas_equalTo(self.collectionView.bottom +20);
  86. make.height.mas_equalTo(kRealValue(355));
  87. }];
  88. [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.top.mas_equalTo(23);
  90. make.centerX.mas_equalTo(0);
  91. }];
  92. [_descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  93. make.top.equalTo(_nameLabel.mas_bottom).offset(6);
  94. make.centerX.mas_equalTo(0);
  95. }];
  96. [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  97. make.top.equalTo(_descLabel.mas_bottom).offset(16);
  98. make.centerX.mas_equalTo(0);
  99. make.left.mas_equalTo(10);
  100. make.height.mas_equalTo(300);
  101. }];
  102. }
  103. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  104. return 1;
  105. }
  106. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  107. return 9;
  108. }
  109. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  110. GuiZuRightsCollectCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([GuiZuRightsCollectCell class]) forIndexPath:indexPath];
  111. return cell;
  112. }
  113. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
  114. return CGSizeMake((kScreenW-14*5)/3, 90);
  115. }
  116. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
  117. return 0;
  118. }
  119. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
  120. return 0;
  121. }
  122. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
  123. // if (section == 0) {
  124. // return UIEdgeInsetsMake(0, 14, 0, 14);
  125. //
  126. // }
  127. return UIEdgeInsetsMake(0, 0, 0, 0);
  128. }
  129. #pragma mark - setter
  130. - (UICollectionView *)collectionView{
  131. if (!_collectionView) {
  132. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
  133. _collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0,0, kScreenW , 300) collectionViewLayout:layout];
  134. _collectionView.delegate = self;
  135. _collectionView.backgroundColor = [UIColor whiteColor];
  136. _collectionView.dataSource = self;
  137. [_collectionView registerClass:[GuiZuRightsCollectCell class] forCellWithReuseIdentifier:NSStringFromClass([GuiZuRightsCollectCell class])];
  138. // [_collectionView registerClass:[RechargeTypeCell class] forCellWithReuseIdentifier:NSStringFromClass([RechargeTypeCell class])];
  139. // [_collectionView registerClass:[SignHeaderCollectReusView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader
  140. // withReuseIdentifier:NSStringFromClass([SignHeaderCollectReusView class])];
  141. // [_collectionView registerClass:[SignFooterCollectReusView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter
  142. // withReuseIdentifier:NSStringFromClass([SignFooterCollectReusView class])];
  143. }
  144. return _collectionView;
  145. }
  146. @end