3
This commit is contained in:
@@ -11,7 +11,8 @@
|
||||
#import "HomeHotCell.h"
|
||||
#import "HomeRankVC.h"
|
||||
#import "KBSearchVC.h"
|
||||
|
||||
#import "HomeRankDetailPopView.h"
|
||||
#import "LSTPopView.h"
|
||||
#import <HWPanModal/HWPanModal.h>
|
||||
@interface HomeHotVC () <UITableViewDataSource, UITableViewDelegate>
|
||||
|
||||
@@ -81,12 +82,39 @@
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
KBSearchVC *vc = [[KBSearchVC alloc] init];
|
||||
// KBSearchVC *vc = [[KBSearchVC alloc] init];
|
||||
// [self.navigationController pushViewController:vc animated:true];
|
||||
UINavigationController *nav = KB_CURRENT_NAV;
|
||||
// UINavigationController *nav = KB_CURRENT_NAV;
|
||||
// [nav pushViewController:vc animated:true];
|
||||
NSLog(@"===");
|
||||
|
||||
// 点击卡片 -> 展示弹窗
|
||||
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 - Lazy
|
||||
|
||||
@@ -22,10 +22,11 @@
|
||||
[self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.top.right.equalTo(self.contentView);
|
||||
// 高度按照宽度等比(接近截图比例)
|
||||
make.height.equalTo(self.contentView.mas_width).multipliedBy(0.58);
|
||||
// make.height.equalTo(self.contentView.mas_width).multipliedBy(0.58);
|
||||
make.height.mas_equalTo(KBFit(264));
|
||||
}];
|
||||
[self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.contentView).offset(12);
|
||||
make.left.equalTo(self.contentView).offset(0);
|
||||
make.top.equalTo(self.coverView.mas_bottom).offset(10);
|
||||
}];
|
||||
[self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.contentView.backgroundColor = [UIColor colorWithWhite:0.96 alpha:1.0];
|
||||
self.contentView.layer.cornerRadius = 16;
|
||||
self.contentView.layer.cornerRadius = 12;
|
||||
self.contentView.layer.masksToBounds = YES;
|
||||
[self.contentView addSubview:self.titleLabel];
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake(6, 12, 6, 12));
|
||||
make.edges.equalTo(self.contentView);
|
||||
}];
|
||||
}
|
||||
return self;
|
||||
@@ -28,10 +28,10 @@
|
||||
}
|
||||
|
||||
+ (CGSize)sizeForText:(NSString *)text {
|
||||
if (text.length == 0) { return CGSizeMake(40, 32); }
|
||||
if (text.length == 0) { return CGSizeMake(40, 24); }
|
||||
CGSize s = [text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]}];
|
||||
// 两侧内边距 12 + 12,高度固定 32
|
||||
return CGSizeMake(ceil(s.width) + 24, 32);
|
||||
return CGSizeMake(ceil(s.width) + 24, 24);
|
||||
}
|
||||
|
||||
#pragma mark - Lazy
|
||||
@@ -39,8 +39,9 @@
|
||||
- (UILabel *)titleLabel {
|
||||
if (!_titleLabel) {
|
||||
_titleLabel = [[UILabel alloc] init];
|
||||
_titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
_titleLabel.textColor = [UIColor colorWithHex:0x1B1F1A];
|
||||
_titleLabel.font = [UIFont systemFontOfSize:12];
|
||||
_titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
_titleLabel.textColor = [UIColor colorWithHex:KBBlackValue];
|
||||
}
|
||||
return _titleLabel;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
self.contentView.backgroundColor = [UIColor whiteColor];
|
||||
[self.contentView addSubview:self.titleLabel];
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.contentView).offset(16);
|
||||
make.left.equalTo(self.contentView).offset(0);
|
||||
make.centerY.equalTo(self.contentView);
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ static NSString * const kInnerTagCellId = @"kInnerTagCellId";
|
||||
UICollectionViewLeftAlignedLayout *layout = [UICollectionViewLeftAlignedLayout new];
|
||||
layout.minimumInteritemSpacing = 8;
|
||||
layout.minimumLineSpacing = 8;
|
||||
layout.sectionInset = UIEdgeInsetsMake(8, 0, 8, 16);
|
||||
layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
|
||||
|
||||
_tagsView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
||||
_tagsView.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
@@ -122,12 +122,12 @@ typedef NS_ENUM(NSInteger, KBSkinDetailSection) {
|
||||
switch (indexPath.section) {
|
||||
case KBSkinDetailSectionHeader: {
|
||||
// 高度 = 图片 0.58W + 文案与上下留白(≈56)
|
||||
CGFloat h = contentW * 0.58 + 56;
|
||||
CGFloat h = KBFit(264) + 30;
|
||||
return CGSizeMake(contentW, h);
|
||||
}
|
||||
case KBSkinDetailSectionTags: {
|
||||
CGFloat h = [KBSkinTagsContainerCell heightForTags:self.tags width:W];
|
||||
return CGSizeMake(contentW, h);
|
||||
return CGSizeMake(contentW, 25);
|
||||
}
|
||||
case KBSkinDetailSectionTitle: {
|
||||
return CGSizeMake(contentW, 44);
|
||||
@@ -144,7 +144,17 @@ typedef NS_ENUM(NSInteger, KBSkinDetailSection) {
|
||||
}
|
||||
|
||||
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
|
||||
return UIEdgeInsetsMake(12, 16, 12, 16);
|
||||
// 控制各区上下留白,缩小 Header 与 Tags 之间的间距
|
||||
switch (section) {
|
||||
case KBSkinDetailSectionHeader:
|
||||
// 顶部与导航之间 12,底部稍微缩小
|
||||
return UIEdgeInsetsMake(12, 16, 4, 16);
|
||||
case KBSkinDetailSectionTags:
|
||||
// 与 Header 更贴近一些
|
||||
return UIEdgeInsetsMake(14, 16, 5, 16);
|
||||
default:
|
||||
return UIEdgeInsetsMake(0, 16, 12, 16);
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
|
||||
|
||||
@@ -78,7 +78,7 @@ typedef NS_ENUM(NSInteger, KBSearchSection) {
|
||||
}];
|
||||
|
||||
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.topBar.mas_bottom).offset(12);
|
||||
make.top.equalTo(self.topBar.mas_bottom).offset(0);
|
||||
make.left.right.bottom.equalTo(self.view);
|
||||
}];
|
||||
|
||||
@@ -310,7 +310,7 @@ typedef NS_ENUM(NSInteger, KBSearchSection) {
|
||||
if (section == KBSearchSectionHistory) {
|
||||
return UIEdgeInsetsMake(8, 16, 12, 16);
|
||||
}
|
||||
return UIEdgeInsetsMake(8, 16, 20, 16);
|
||||
return UIEdgeInsetsMake(8, 16, 16, 16);
|
||||
}
|
||||
|
||||
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
|
||||
@@ -326,7 +326,7 @@ typedef NS_ENUM(NSInteger, KBSearchSection) {
|
||||
if (section == KBSearchSectionHistory) {
|
||||
return self.historyWords.count == 0 ? CGSizeZero : CGSizeMake(collectionView.bounds.size.width, 40);
|
||||
}
|
||||
return CGSizeMake(collectionView.bounds.size.width, 40);
|
||||
return CGSizeMake(collectionView.bounds.size.width, 24);
|
||||
}
|
||||
|
||||
#pragma mark - UICollectionViewDelegate
|
||||
|
||||
Reference in New Issue
Block a user