添加弹窗
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
|
||||
@import UIKit;
|
||||
#import "HomeRankContentVC.h"
|
||||
#import "HomeRankDetailPopView.h" // 自定义弹窗内容视图
|
||||
#import "LSTPopView.h" // LSTPopView 弹窗框架
|
||||
|
||||
// 自定义卡片 Cell
|
||||
#import "HomeRankCardCell.h"
|
||||
@@ -92,16 +94,44 @@
|
||||
#pragma mark - UICollectionViewDelegateFlowLayout
|
||||
|
||||
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||
CGFloat totalHInset = 16 + 16; // section i/l/r
|
||||
CGFloat spacing = 16; // interitem spacing
|
||||
CGFloat w = collectionView.bounds.size.width - totalHInset; // not including section insets yet
|
||||
// Two columns → each width = (width - spacing - lr insets)/2
|
||||
CGFloat totalHInset = 16 + 16;
|
||||
CGFloat spacing = 16;
|
||||
CGFloat w = collectionView.bounds.size.width - totalHInset;
|
||||
CGFloat cellWidth = (w - spacing) / 2.0;
|
||||
// 固定高度,接近示意图比例
|
||||
CGFloat cellHeight = 234.0;
|
||||
return CGSizeMake(floor(cellWidth), cellHeight);
|
||||
}
|
||||
|
||||
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
// 点击卡片 -> 展示弹窗
|
||||
NSDictionary *d = self.dataSource[indexPath.item];
|
||||
|
||||
// 自定义内容视图(尺寸可按需调节)
|
||||
CGFloat width = MIN(KB_SCREEN_WIDTH - 76, 420);
|
||||
HomeRankDetailPopView *content = [[HomeRankDetailPopView alloc] initWithFrame:CGRectMake(0, 0, width, 460)];
|
||||
NSString *title = d[@"title"] ?: @"High EQ";
|
||||
NSString *people = d[@"people"] ?: @"Download: 1 Million";
|
||||
NSString *desc = @"Be Neither Too Close\nNor Too Distant"; // 示例文案
|
||||
[content configWithAvatar:nil title:title download:people desc:desc];
|
||||
|
||||
// 创建并弹出
|
||||
LSTPopView *pop = [LSTPopView initWithCustomView:content
|
||||
parentView:nil
|
||||
popStyle:LSTPopStyleScale
|
||||
dismissStyle:LSTDismissStyleScale];
|
||||
pop.hemStyle = LSTHemStyleCenter; // 居中
|
||||
pop.bgColor = [[UIColor blackColor] colorWithAlphaComponent:0.4];
|
||||
pop.isClickBgDismiss = YES; // 点击背景关闭
|
||||
pop.cornerRadius = 0; // 自定义 view 自处理圆角
|
||||
|
||||
__weak typeof(pop) weakPop = pop;
|
||||
content.saveHandler = ^{ [weakPop dismiss]; };
|
||||
content.closeHandler = ^{ [weakPop dismiss]; };
|
||||
|
||||
[pop pop];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - JXCategoryListContentViewDelegate
|
||||
- (UIView *)listView {
|
||||
|
||||
Reference in New Issue
Block a user