1
This commit is contained in:
@@ -19,6 +19,7 @@ static NSString * const kKBVipReviewListCellId = @"kKBVipReviewListCellId";
|
||||
@property (nonatomic, strong) NSArray<NSDictionary *> *plans; // 订阅方案数组
|
||||
@property (nonatomic, assign) NSInteger selectedIndex; // 当前选中的方案索引
|
||||
@property (nonatomic, strong) UIButton *closeButton; // 当前选中的方案索引
|
||||
@property (nonatomic, strong) UIImageView *bgImageView; // 全屏背景图
|
||||
|
||||
@end
|
||||
|
||||
@@ -29,9 +30,15 @@ static NSString * const kKBVipReviewListCellId = @"kKBVipReviewListCellId";
|
||||
// 标题与导航样式
|
||||
// self.kb_titleLabel.text = @"VIP";
|
||||
// self.kb_navView.backgroundColor = [UIColor clearColor];
|
||||
|
||||
self.view.backgroundColor = [UIColor colorWithWhite:0.97 alpha:1.0];
|
||||
|
||||
self.view.backgroundColor = [UIColor colorWithHex:0xF6F7FB];
|
||||
self.kb_enableCustomNavBar = NO;
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pay_vipbg_icon"]];
|
||||
self.bgImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
[self.view addSubview:self.bgImageView];
|
||||
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.top.right.equalTo(self.view);
|
||||
make.height.mas_equalTo(224);
|
||||
}];
|
||||
// 初始化数据(简单演示)
|
||||
self.plans = @[
|
||||
@{@"title":@"Monthly Subscription", @"price":@"$4.49", @"strike":@"$4.49"},
|
||||
@@ -39,17 +46,18 @@ static NSString * const kKBVipReviewListCellId = @"kKBVipReviewListCellId";
|
||||
@{@"title":@"Monthly Subscription", @"price":@"$4.49", @"strike":@"$4.49"},
|
||||
];
|
||||
self.selectedIndex = 1; // 默认选中第二项
|
||||
[self.view addSubview:self.closeButton];
|
||||
[self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.view).offset(KB_NAV_TOTAL_HEIGHT);
|
||||
make.left.equalTo(self.view).offset(15);
|
||||
make.width.height.mas_equalTo(36);
|
||||
}];
|
||||
|
||||
// 组装主列表
|
||||
[self.view addSubview:self.collectionView];
|
||||
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.bottom.equalTo(self.view);
|
||||
make.top.equalTo(self.view).offset(KB_NAV_TOTAL_HEIGHT);
|
||||
make.top.equalTo(self.view).offset(0);
|
||||
}];
|
||||
[self.view addSubview:self.closeButton];
|
||||
[self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.view).offset(KB_NAV_TOTAL_HEIGHT - 30);
|
||||
make.left.equalTo(self.view).offset(15);
|
||||
make.width.height.mas_equalTo(36);
|
||||
}];
|
||||
|
||||
[self.collectionView reloadData];
|
||||
@@ -67,6 +75,11 @@ static NSString * const kKBVipReviewListCellId = @"kKBVipReviewListCellId";
|
||||
if (cell) { [cell applySelected:YES animated:NO]; }
|
||||
}
|
||||
|
||||
#pragma mark - Action
|
||||
- (void)onTapClose{
|
||||
[self.navigationController popViewControllerAnimated:true];
|
||||
}
|
||||
|
||||
#pragma mark - UICollectionView DataSource
|
||||
|
||||
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
|
||||
@@ -133,7 +146,7 @@ static NSString * const kKBVipReviewListCellId = @"kKBVipReviewListCellId";
|
||||
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||
CGFloat w = KB_SCREEN_WIDTH - 32;
|
||||
if (indexPath.section == 1) {
|
||||
return CGSizeMake(w, 106);
|
||||
return CGSizeMake(w, KBFit(75 + 6));
|
||||
} else {
|
||||
return CGSizeMake(w, 140);
|
||||
}
|
||||
@@ -142,7 +155,7 @@ static NSString * const kKBVipReviewListCellId = @"kKBVipReviewListCellId";
|
||||
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
|
||||
if (section == 0) {
|
||||
// 头部高度 = 484 + 导航栏高度
|
||||
return CGSizeMake(KB_SCREEN_WIDTH, 484 + KB_NAV_TOTAL_HEIGHT);
|
||||
return CGSizeMake(KB_SCREEN_WIDTH, 474 + KB_NAV_TOTAL_HEIGHT);
|
||||
}
|
||||
return CGSizeZero;
|
||||
}
|
||||
@@ -154,7 +167,8 @@ static NSString * const kKBVipReviewListCellId = @"kKBVipReviewListCellId";
|
||||
|
||||
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
|
||||
if (section == 1) {
|
||||
return UIEdgeInsetsMake(0, 16, 10, 16);
|
||||
// 留出顶部间距,避免第一个订阅 cell 的边框被 header 盖住
|
||||
return UIEdgeInsetsMake(16, 16, 10, 16);
|
||||
} else if (section == 2) {
|
||||
return UIEdgeInsetsMake(10, 16, 20, 16);
|
||||
}
|
||||
@@ -185,7 +199,7 @@ static NSString * const kKBVipReviewListCellId = @"kKBVipReviewListCellId";
|
||||
- (UIButton *)closeButton {
|
||||
if (!_closeButton) {
|
||||
_closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_closeButton setImage:[UIImage imageNamed:@"white_close_icon"] forState:UIControlStateNormal];
|
||||
[_closeButton setImage:[UIImage imageNamed:@"close_white2_icon"] forState:UIControlStateNormal];
|
||||
[_closeButton addTarget:self action:@selector(onTapClose) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _closeButton;
|
||||
|
||||
Reference in New Issue
Block a user