diff --git a/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftCollectionViewFlowLayout.m b/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftCollectionViewFlowLayout.m index 8116efa7..24701665 100644 --- a/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftCollectionViewFlowLayout.m +++ b/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftCollectionViewFlowLayout.m @@ -77,11 +77,14 @@ if(attributes.representedElementKind != nil){ return; } + CGFloat minLine = self.minimumLineSpacing; + CGFloat minSpacing = self.minimumInteritemSpacing; + //attributes 的宽度 CGFloat itemW = attributes.frame.size.width; //attributes 的高度 CGFloat itemH = attributes.frame.size.height; - + UIEdgeInsets sectionInsets = self.sectionInset; //collectionView 的宽度 CGFloat width = self.collectionView.frame.size.width; //collectionView 的高度 @@ -116,9 +119,9 @@ //x方向每个item的偏移量 - CGFloat xCellOffset = remain * itemW; + CGFloat xCellOffset = remain * (itemW + minLine)+ sectionInsets.left; //y方向每个item的偏移量 - CGFloat yCellOffset = merchant * itemH; + CGFloat yCellOffset = merchant * (itemH + minSpacing); //获取每个section中item占了几页 NSInteger pageRe = (itemCount % allCount == 0)? (itemCount / allCount) : (itemCount / allCount) + 1; diff --git a/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftUserCollectionViewCell.m b/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftUserCollectionViewCell.m index 5a975771..85cb9c90 100644 --- a/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftUserCollectionViewCell.m +++ b/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftUserCollectionViewCell.m @@ -20,6 +20,8 @@ @interface XPGiftUserCollectionViewCell () ///头像 @property (nonatomic,strong) NetImageView *avatarImageView; +///背景图 +@property (nonatomic,strong) UIView * coverView; ///当前位置的 @property (nonatomic,strong) UILabel *positionLabel; @end @@ -37,6 +39,7 @@ #pragma mark - Private Method - (void)initSubViews { [self.contentView addSubview:self.avatarImageView]; + [self.contentView addSubview:self.coverView]; [self.contentView addSubview:self.positionLabel]; } @@ -46,6 +49,10 @@ make.width.height.mas_equalTo(38); }]; + [self.coverView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self.avatarImageView); + }]; + [self.positionLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(10); make.centerY.mas_equalTo(self.avatarImageView.mas_bottom); @@ -82,8 +89,12 @@ self.avatarImageView.imageUrl = _userInfo.avatar; if (_userInfo.isSelect) { self.avatarImageView.layer.borderWidth = 2; + self.coverView.hidden = YES; + self.positionLabel.backgroundColor = [ThemeColor appMainColor]; } else { self.avatarImageView.layer.borderWidth = 0; + self.coverView.hidden = NO; + self.positionLabel.backgroundColor = [ThemeColor textThirdColor]; } } @@ -100,11 +111,21 @@ return _avatarImageView; } +- (UIView *)coverView { + if (!_coverView) { + _coverView = [[UIView alloc] init]; + _coverView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3]; + _coverView.layer.cornerRadius = 38/2; + _coverView.layer.masksToBounds = YES; + } + return _coverView; +} + - (UILabel *)positionLabel{ if (!_positionLabel) { _positionLabel = [[UILabel alloc] init]; _positionLabel.font = [UIFont systemFontOfSize:8]; - _positionLabel.textColor = [ThemeColor mainTextColor]; + _positionLabel.textColor = [UIColor whiteColor]; _positionLabel.textAlignment = NSTextAlignmentCenter; _positionLabel.backgroundColor = [ThemeColor appMainColor]; _positionLabel.layer.masksToBounds = YES; diff --git a/xplan-ios/Main/ModuleKit/SendGiftView/View/XPGiftInfoView.m b/xplan-ios/Main/ModuleKit/SendGiftView/View/XPGiftInfoView.m index 717cb0d2..dd5bf48d 100644 --- a/xplan-ios/Main/ModuleKit/SendGiftView/View/XPGiftInfoView.m +++ b/xplan-ios/Main/ModuleKit/SendGiftView/View/XPGiftInfoView.m @@ -111,7 +111,7 @@ - (void)initSubViewConstraints { [self mas_makeConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(40 + 105 * 2 + 10 + 10); + make.height.mas_equalTo(40 + 108 * 2 + 10 + 10); }]; @@ -124,7 +124,13 @@ [self.giftStackView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.segmentStackView.mas_bottom); make.left.right.mas_equalTo(self); - make.height.mas_equalTo(105 * 2 + 20); + make.height.mas_equalTo(108 * 2 + 20); + }]; + + + [self.giftcollectionView + mas_makeConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(108 * 2 + 10); }]; [self.pageController mas_makeConstraints:^(MASConstraintMaker *make) { @@ -204,8 +210,8 @@ if (self.segmentType == GiftSegmentType_Pack && self.datasource.count == 0) { return CGSizeMake(KScreenWidth, 105 * 2 + 10); } - CGFloat itemWidth = (CGFloat)(KScreenWidth - 10 - 5 * 3) / (CGFloat)4; - return CGSizeMake(itemWidth, 105); + CGFloat itemWidth = (CGFloat)(KScreenWidth - 15 * 2 - 5 * 3) / (CGFloat)4; + return CGSizeMake(itemWidth, 108); } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { @@ -234,7 +240,6 @@ GiftInfoModel * giftInfo= [self.datasource objectAtIndex:indexPath.item]; [self dealSelectGift:giftInfo]; [self.giftcollectionView reloadData]; - } } @@ -395,10 +400,9 @@ - (UICollectionView *)giftcollectionView{ if (!_giftcollectionView) { XPGiftCollectionViewFlowLayout *layout = [[XPGiftCollectionViewFlowLayout alloc] init]; - layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; layout.minimumLineSpacing = 5; - layout.minimumInteritemSpacing = 10; - layout.sectionInset = UIEdgeInsetsMake(0, 15, 0, 5); + layout.minimumInteritemSpacing = 5; + layout.sectionInset = UIEdgeInsetsMake(0, 15, 0, 15); _giftcollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; _giftcollectionView.dataSource = self; _giftcollectionView.delegate = self;