This commit is contained in:
2025-11-15 00:33:29 +08:00
parent 1f9dbba39d
commit f9a8955384
5 changed files with 68 additions and 14 deletions

View File

@@ -45,7 +45,7 @@
[self.wanImageView mas_makeConstraints:^(MASConstraintMaker *make) { [self.wanImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.left.equalTo(self.containerView); make.right.left.equalTo(self.containerView);
make.top.equalTo(self.vipImageView).offset(70); make.top.equalTo(self.vipImageView).offset(70);
make.bottom.equalTo(self.containerView); make.bottom.equalTo(self.containerView).offset(-16);
}]; }];
[self.containerView addSubview:self.titleLabel]; [self.containerView addSubview:self.titleLabel];
@@ -74,7 +74,7 @@
[g1 mas_makeConstraints:^(MASConstraintMaker *make) { [g1 mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.vipImageView); make.left.equalTo(self.vipImageView);
make.top.equalTo(self.desLabel.mas_bottom).offset(18); make.top.equalTo(self.desLabel.mas_bottom).offset(18);
make.height.mas_equalTo(((113))); make.height.mas_equalTo(((KBFit(122))));
}]; }];
[g2 mas_makeConstraints:^(MASConstraintMaker *make) { [g2 mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.vipImageView); make.right.equalTo(self.vipImageView);
@@ -95,12 +95,29 @@
make.left.equalTo(g3.mas_right).offset(spacing); make.left.equalTo(g3.mas_right).offset(spacing);
make.height.equalTo(g1); make.height.equalTo(g1);
make.width.equalTo(g1); make.width.equalTo(g1);
// make.bottom.lessThanOrEqualTo(self.containerView).offset(-12); // header
make.bottom.equalTo(self.containerView).offset(-12);
}]; }];
} }
return self; return self;
} }
// header AutoLayout
- (UICollectionViewLayoutAttributes *)preferredLayoutAttributesFittingAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
CGFloat targetWidth = layoutAttributes.size.width > 0 ? layoutAttributes.size.width : KB_SCREEN_WIDTH;
// 便
self.bounds = CGRectMake(0, 0, targetWidth, self.bounds.size.height);
[self setNeedsLayout];
[self layoutIfNeeded];
CGSize fit = [self systemLayoutSizeFittingSize:CGSizeMake(targetWidth, UILayoutFittingCompressedSize.height)
withHorizontalFittingPriority:UILayoutPriorityRequired
verticalFittingPriority:UILayoutPriorityFittingSizeLevel];
CGRect f = layoutAttributes.frame;
f.size.height = ceil(fit.height);
layoutAttributes.frame = f;
return layoutAttributes;
}
#pragma mark - Helpers #pragma mark - Helpers
- (UIView *)gridItemWithImageView:(UIImageView *)iv { - (UIView *)gridItemWithImageView:(UIImageView *)iv {
// //
@@ -109,7 +126,7 @@
// v.layer.cornerRadius = 12; // v.layer.cornerRadius = 12;
// v.layer.masksToBounds = YES; // v.layer.masksToBounds = YES;
[v addSubview:iv]; [v addSubview:iv];
iv.contentMode = UIViewContentModeScaleAspectFill; iv.contentMode = UIViewContentModeScaleAspectFit;
[iv mas_makeConstraints:^(MASConstraintMaker *make) { [iv mas_makeConstraints:^(MASConstraintMaker *make) {
// make.center.equalTo(v); // make.center.equalTo(v);
// make.width.height.mas_equalTo(40); // make.width.height.mas_equalTo(40);
@@ -193,4 +210,3 @@
} }
@end @end

View File

@@ -98,11 +98,13 @@
_heartsStack.spacing = 4; _heartsStack.spacing = 4;
_heartsStack.alignment = UIStackViewAlignmentCenter; _heartsStack.alignment = UIStackViewAlignmentCenter;
_heartsStack.distribution = UIStackViewDistributionFillProportionally; _heartsStack.distribution = UIStackViewDistributionFillProportionally;
for (int i = 0; i < 5; i++) { for (int i = 0; i < 1; i++) {
UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pay_5aixin_icon"]]; UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pay_5aixin_icon"]];
iv.contentMode = UIViewContentModeScaleAspectFit; iv.contentMode = UIViewContentModeScaleAspectFit;
[iv mas_makeConstraints:^(MASConstraintMaker *make) { [iv mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(16); make.height.mas_equalTo(10);
make.width.mas_equalTo(77);
}]; }];
[_heartsStack addArrangedSubview:iv]; [_heartsStack addArrangedSubview:iv];
} }

View File

@@ -57,7 +57,7 @@ static NSString * const kKBVipReviewItemCellId = @"kKBVipReviewItemCellId";
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section { return 10; } - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section { return 10; }
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section { return 10; } - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section { return 10; }
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section { - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
return UIEdgeInsetsMake(0, 16, 0, 16); return UIEdgeInsetsMake(0, 0, 0, 16);
} }
#pragma mark - Lazy #pragma mark - Lazy

View File

@@ -22,10 +22,9 @@
self.contentView.backgroundColor = [UIColor clearColor]; self.contentView.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:self.cardView]; [self.contentView addSubview:self.cardView];
// self.cardView.backgroundColor = [UIColor redColor];
[self.cardView mas_makeConstraints:^(MASConstraintMaker *make) { [self.cardView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.contentView); make.left.right.equalTo(self.contentView);
make.top.equalTo(self.contentView).inset(6); make.top.equalTo(self.contentView).inset(0);
make.bottom.equalTo(self.contentView); make.bottom.equalTo(self.contentView);
}]; }];
@@ -37,11 +36,11 @@
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.cardView).offset(16); make.left.equalTo(self.cardView).offset(16);
make.top.equalTo(self.cardView).offset(11); make.bottom.equalTo(self.cardView.mas_centerY).offset(-5);
}]; }];
[self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) { [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.titleLabel); make.left.equalTo(self.titleLabel);
make.top.equalTo(self.titleLabel.mas_bottom).offset(6); make.top.equalTo(self.cardView.mas_centerY).offset(3);
}]; }];
[self.strikeLabel mas_makeConstraints:^(MASConstraintMaker *make) { [self.strikeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.priceLabel.mas_right).offset(10); make.left.equalTo(self.priceLabel.mas_right).offset(10);

View File

@@ -20,6 +20,9 @@ static NSString * const kKBVipReviewListCellId = @"kKBVipReviewListCellId";
@property (nonatomic, assign) NSInteger selectedIndex; // @property (nonatomic, assign) NSInteger selectedIndex; //
@property (nonatomic, strong) UIButton *closeButton; // @property (nonatomic, strong) UIButton *closeButton; //
@property (nonatomic, strong) UIImageView *bgImageView; // @property (nonatomic, strong) UIImageView *bgImageView; //
// Header
@property (nonatomic, strong) KBVipPayHeaderView *sizingHeader;
@property (nonatomic, assign) CGFloat headerHeight;
@end @end
@@ -60,6 +63,8 @@ static NSString * const kKBVipReviewListCellId = @"kKBVipReviewListCellId";
make.width.height.mas_equalTo(36); make.width.height.mas_equalTo(36);
}]; }];
// Header
self.headerHeight = [self kb_calcHeaderHeightForWidth:KB_SCREEN_WIDTH];
[self.collectionView reloadData]; [self.collectionView reloadData];
} }
@@ -75,6 +80,22 @@ static NSString * const kKBVipReviewListCellId = @"kKBVipReviewListCellId";
if (cell) { [cell applySelected:YES animated:NO]; } if (cell) { [cell applySelected:YES animated:NO]; }
} }
#pragma mark - Header Height Calc
- (CGFloat)kb_calcHeaderHeightForWidth:(CGFloat)width {
if (width <= 0) { width = KB_SCREEN_WIDTH; }
if (!self.sizingHeader) {
self.sizingHeader = [[KBVipPayHeaderView alloc] initWithFrame:CGRectMake(0, 0, width, 1)];
}
//
self.sizingHeader.bounds = CGRectMake(0, 0, width, self.sizingHeader.bounds.size.height);
[self.sizingHeader setNeedsLayout];
[self.sizingHeader layoutIfNeeded];
CGSize size = [self.sizingHeader systemLayoutSizeFittingSize:CGSizeMake(width, UILayoutFittingCompressedSize.height)
withHorizontalFittingPriority:UILayoutPriorityRequired
verticalFittingPriority:UILayoutPriorityFittingSizeLevel];
return MAX(1, ceil(size.height));
}
#pragma mark - Action #pragma mark - Action
- (void)onTapClose{ - (void)onTapClose{
[self.navigationController popViewControllerAnimated:true]; [self.navigationController popViewControllerAnimated:true];
@@ -154,8 +175,10 @@ static NSString * const kKBVipReviewListCellId = @"kKBVipReviewListCellId";
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section { - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
if (section == 0) { if (section == 0) {
// = 484 + // Header
return CGSizeMake(KB_SCREEN_WIDTH, 474 + KB_NAV_TOTAL_HEIGHT); CGFloat w = collectionView.bounds.size.width ?: KB_SCREEN_WIDTH;
if (self.headerHeight <= 1) { self.headerHeight = [self kb_calcHeaderHeightForWidth:w]; }
return CGSizeMake(w, self.headerHeight);
} }
return CGSizeZero; return CGSizeZero;
} }
@@ -180,6 +203,8 @@ static NSString * const kKBVipReviewListCellId = @"kKBVipReviewListCellId";
if (!_collectionView) { if (!_collectionView) {
UICollectionViewFlowLayout *layout = [UICollectionViewFlowLayout new]; UICollectionViewFlowLayout *layout = [UICollectionViewFlowLayout new];
layout.scrollDirection = UICollectionViewScrollDirectionVertical; layout.scrollDirection = UICollectionViewScrollDirectionVertical;
// 便 header
layout.sectionHeadersPinToVisibleBounds = NO;
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
_collectionView.backgroundColor = [UIColor clearColor]; _collectionView.backgroundColor = [UIColor clearColor];
_collectionView.dataSource = self; _collectionView.dataSource = self;
@@ -204,4 +229,16 @@ static NSString * const kKBVipReviewListCellId = @"kKBVipReviewListCellId";
} }
return _closeButton; return _closeButton;
} }
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
// Header
CGFloat w = self.collectionView.bounds.size.width ?: KB_SCREEN_WIDTH;
CGFloat newH = [self kb_calcHeaderHeightForWidth:w];
if (fabs(newH - self.headerHeight) > 0.5) {
self.headerHeight = newH;
UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout;
[layout invalidateLayout];
}
}
@end @end