添加homeheadView
This commit is contained in:
@@ -19,10 +19,9 @@
|
||||
0477BDFD2EBC6A170055D639 /* HomeHotVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BDFC2EBC6A170055D639 /* HomeHotVC.m */; };
|
||||
0477BE002EBC6A330055D639 /* HomeRankVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BDFF2EBC6A330055D639 /* HomeRankVC.m */; };
|
||||
0477BE042EBC83130055D639 /* HomeMainVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BE032EBC83130055D639 /* HomeMainVC.m */; };
|
||||
0477BEA22EBCF0000055D639 /* KBTopImageButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BEA12EBCF0000055D639 /* KBTopImageButton.m */; };
|
||||
047C650D2EBC8A840035E841 /* KBPanModalView.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C650C2EBC8A840035E841 /* KBPanModalView.m */; };
|
||||
047C65102EBCA8DD0035E841 /* HomeRankContentVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C650F2EBCA8DD0035E841 /* HomeRankContentVC.m */; };
|
||||
047C655C2EBCD0F80035E841 /* UIView+KBShadow.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C655B2EBCD08E0035E841 /* UIView+KBShadow.m */; };
|
||||
047C655E2EBCD5B20035E841 /* UIImage+KBColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C655D2EBCD5B20035E841 /* UIImage+KBColor.m */; };
|
||||
047C652D2EBCAAAC0035E841 /* crab_selected.png in Resources */ = {isa = PBXBuildFile; fileRef = 047C651F2EBCAAAC0035E841 /* crab_selected.png */; };
|
||||
047C652E2EBCAAAC0035E841 /* crab.png in Resources */ = {isa = PBXBuildFile; fileRef = 047C651E2EBCAAAC0035E841 /* crab.png */; };
|
||||
047C652F2EBCAAAC0035E841 /* arrow_down.png in Resources */ = {isa = PBXBuildFile; fileRef = 047C651A2EBCAAAC0035E841 /* arrow_down.png */; };
|
||||
@@ -51,6 +50,8 @@
|
||||
047C65502EBCBA9E0035E841 /* KBShopVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C654F2EBCBA9E0035E841 /* KBShopVC.m */; };
|
||||
047C65532EBCBAC60035E841 /* KBCommunityVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C65522EBCBAC60035E841 /* KBCommunityVC.m */; };
|
||||
047C65582EBCC06D0035E841 /* HomeRankCardCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C65572EBCC06D0035E841 /* HomeRankCardCell.m */; };
|
||||
047C655C2EBCD0F80035E841 /* UIView+KBShadow.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C655B2EBCD08E0035E841 /* UIView+KBShadow.m */; };
|
||||
047C655E2EBCD5B20035E841 /* UIImage+KBColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 047C655D2EBCD5B20035E841 /* UIImage+KBColor.m */; };
|
||||
04A9FE0F2EB481100020DB6D /* KBHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC97082EB31B14007BD342 /* KBHUD.m */; };
|
||||
04A9FE132EB4D0D20020DB6D /* KBFullAccessManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A9FE112EB4D0D20020DB6D /* KBFullAccessManager.m */; };
|
||||
04A9FE162EB873C80020DB6D /* UIViewController+Extension.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A9FE152EB873C80020DB6D /* UIViewController+Extension.m */; };
|
||||
@@ -152,6 +153,8 @@
|
||||
0477BDFF2EBC6A330055D639 /* HomeRankVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeRankVC.m; sourceTree = "<group>"; };
|
||||
0477BE022EBC83130055D639 /* HomeMainVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeMainVC.h; sourceTree = "<group>"; };
|
||||
0477BE032EBC83130055D639 /* HomeMainVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeMainVC.m; sourceTree = "<group>"; };
|
||||
0477BEA02EBCF0000055D639 /* KBTopImageButton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBTopImageButton.h; sourceTree = "<group>"; };
|
||||
0477BEA12EBCF0000055D639 /* KBTopImageButton.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBTopImageButton.m; sourceTree = "<group>"; };
|
||||
047C650B2EBC8A840035E841 /* KBPanModalView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBPanModalView.h; sourceTree = "<group>"; };
|
||||
047C650C2EBC8A840035E841 /* KBPanModalView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBPanModalView.m; sourceTree = "<group>"; };
|
||||
047C650E2EBCA8DD0035E841 /* HomeRankContentVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeRankContentVC.h; sourceTree = "<group>"; };
|
||||
@@ -454,6 +457,21 @@
|
||||
path = Shop;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
048908B82EBDC11200FABA60 /* V */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
);
|
||||
path = V;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
048908B92EBDC11200FABA60 /* Common */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
048908B82EBDC11200FABA60 /* V */,
|
||||
);
|
||||
path = Common;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
04A9FE122EB4D0D20020DB6D /* Manager */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -567,6 +585,8 @@
|
||||
0477BDF22EBB7B850055D639 /* KBDirectionIndicatorView.m */,
|
||||
0477BDF82EBC66340055D639 /* HomeHeadView.h */,
|
||||
0477BDF92EBC66340055D639 /* HomeHeadView.m */,
|
||||
0477BEA02EBCF0000055D639 /* KBTopImageButton.h */,
|
||||
0477BEA12EBCF0000055D639 /* KBTopImageButton.m */,
|
||||
A1B2E0012EBC7AAA00000001 /* KBTopThreeView.h */,
|
||||
A1B2E0022EBC7AAA00000001 /* KBTopThreeView.m */,
|
||||
A1B2E0032EBC7AAA00000001 /* HomeHotCell.h */,
|
||||
@@ -676,6 +696,7 @@
|
||||
04FC95BF2EB1E3B1007BD342 /* Class */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
048908B92EBDC11200FABA60 /* Common */,
|
||||
04FC95B62EB1E3B1007BD342 /* Home */,
|
||||
047C654D2EBCBA880035E841 /* Shop */,
|
||||
047C65492EBCBA880035E841 /* Community */,
|
||||
@@ -1175,6 +1196,7 @@
|
||||
047C65502EBCBA9E0035E841 /* KBShopVC.m in Sources */,
|
||||
0477BE042EBC83130055D639 /* HomeMainVC.m in Sources */,
|
||||
0477BDFD2EBC6A170055D639 /* HomeHotVC.m in Sources */,
|
||||
0477BEA22EBCF0000055D639 /* KBTopImageButton.m in Sources */,
|
||||
A1B2E1012EBC7AAA00000001 /* KBTopThreeView.m in Sources */,
|
||||
A1B2E1022EBC7AAA00000001 /* HomeHotCell.m in Sources */,
|
||||
0459D1B72EBA287900F2D189 /* KBSkinManager.m in Sources */,
|
||||
|
||||
@@ -11,6 +11,13 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface HomeHeadView : UIView
|
||||
|
||||
/// 点击底部购买按钮回调
|
||||
@property (nonatomic, copy) void (^onTapBuy)(void);
|
||||
|
||||
/// 配置4个功能按钮标题与图片(可选)
|
||||
/// 若 images 为空会使用一个渐变占位图
|
||||
- (void)configureFeatureTitles:(NSArray<NSString *> *)titles images:(NSArray<UIImage *> * _Nullable)images;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -6,14 +6,244 @@
|
||||
//
|
||||
|
||||
#import "HomeHeadView.h"
|
||||
#import "UIImage+KBColor.h"
|
||||
#import "KBTopImageButton.h"
|
||||
|
||||
|
||||
@interface HomeHeadView()
|
||||
// 顶部会员卡图片
|
||||
@property (nonatomic, strong) UIImageView *vipImageView;
|
||||
// 主/副标题
|
||||
@property (nonatomic, strong) UILabel *titleLabel;
|
||||
@property (nonatomic, strong) UILabel *subTitleLabel;
|
||||
// 中部四个功能按钮容器
|
||||
@property (nonatomic, strong) UIView *featuresContainer;
|
||||
@property (nonatomic, strong) NSArray<KBTopImageButton *> *featureButtons;
|
||||
// 底部购买按钮
|
||||
@property (nonatomic, strong) UIButton *buyButton;
|
||||
|
||||
@end
|
||||
|
||||
@implementation HomeHeadView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
[self setupViews];
|
||||
[self setupConstraints];
|
||||
[self defaultData];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Layout
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
// 根据实际尺寸更新购买按钮背景的渐变图(避免在未布局前计算尺寸为0)
|
||||
if (self.buyButton.currentBackgroundImage == nil) {
|
||||
CGSize size = self.buyButton.bounds.size;
|
||||
if (size.width > 0 && size.height > 0) {
|
||||
UIImage *bg = [UIImage kb_gradientImageWithColors:@[[UIColor colorWithHex:0xE6FFF4], [UIColor colorWithHex:0xA6FFD8]]
|
||||
locations:nil
|
||||
size:size
|
||||
direction:KBGradientDirectionLeftToRight
|
||||
cornerRadius:size.height * 0.5];
|
||||
[self.buyButton setBackgroundImage:bg forState:UIControlStateNormal];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UI
|
||||
- (void)setupViews {
|
||||
[self addSubview:self.vipImageView];
|
||||
[self addSubview:self.titleLabel];
|
||||
[self addSubview:self.subTitleLabel];
|
||||
[self addSubview:self.featuresContainer];
|
||||
[self addSubview:self.buyButton];
|
||||
}
|
||||
|
||||
- (void)setupConstraints {
|
||||
// 顶部图
|
||||
[self.vipImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.mas_top).offset(2);
|
||||
make.centerX.equalTo(self);
|
||||
make.width.mas_equalTo(217);
|
||||
make.height.mas_equalTo(166);
|
||||
}];
|
||||
|
||||
// 主标题
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.vipImageView.mas_bottom).offset(28);
|
||||
make.centerX.equalTo(self);
|
||||
make.left.greaterThanOrEqualTo(self.mas_left).offset(16);
|
||||
make.right.lessThanOrEqualTo(self.mas_right).offset(-16);
|
||||
make.height.mas_equalTo(26);
|
||||
}];
|
||||
|
||||
// 副标题
|
||||
[self.subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.titleLabel.mas_bottom).offset(3);
|
||||
make.centerX.equalTo(self.titleLabel);
|
||||
make.left.greaterThanOrEqualTo(self.mas_left).offset(16);
|
||||
make.right.lessThanOrEqualTo(self.mas_right).offset(-16);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
|
||||
// 功能按钮容器
|
||||
[self.featuresContainer mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.subTitleLabel.mas_bottom).offset(16);
|
||||
make.left.equalTo(self.mas_left).offset(16);
|
||||
make.right.equalTo(self.mas_right).offset(-16);
|
||||
make.height.mas_equalTo(94);
|
||||
}];
|
||||
|
||||
// 四个按钮等宽分布
|
||||
KBTopImageButton *b0 = self.featureButtons[0];
|
||||
KBTopImageButton *b1 = self.featureButtons[1];
|
||||
KBTopImageButton *b2 = self.featureButtons[2];
|
||||
KBTopImageButton *b3 = self.featureButtons[3];
|
||||
|
||||
[b0 mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.top.bottom.equalTo(self.featuresContainer);
|
||||
}];
|
||||
[b1 mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(b0.mas_right);
|
||||
make.top.bottom.equalTo(b0);
|
||||
make.width.equalTo(b0);
|
||||
}];
|
||||
[b2 mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(b1.mas_right);
|
||||
make.top.bottom.equalTo(b0);
|
||||
make.width.equalTo(b0);
|
||||
}];
|
||||
[b3 mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(b2.mas_right);
|
||||
make.top.bottom.right.equalTo(self.featuresContainer);
|
||||
make.width.equalTo(b0);
|
||||
}];
|
||||
|
||||
// 购买按钮
|
||||
[self.buyButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.mas_left).offset(62);
|
||||
make.right.equalTo(self.mas_right).offset(-62);
|
||||
make.bottom.equalTo(self.mas_bottom).offset(-5);
|
||||
make.height.mas_equalTo(56);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)defaultData {
|
||||
// 默认文案(使用英文,便于与示例图一致)
|
||||
self.titleLabel.text = @"Become A Member Of Love Key";
|
||||
self.subTitleLabel.text = @"Unlock All Functions";
|
||||
|
||||
NSArray *titles = @[@"Wireless Sub-ai\nDialogue",
|
||||
@"Personalized\nKeyboard",
|
||||
@"Chat\nPersona",
|
||||
@"Emotional\nCounseling"];
|
||||
[self configureFeatureTitles:titles images:nil];
|
||||
}
|
||||
|
||||
#pragma mark - Public
|
||||
- (void)configureFeatureTitles:(NSArray<NSString *> *)titles images:(NSArray<UIImage *> *)images {
|
||||
// 设置四个按钮标题与占位图片(如未传图片则生成渐变圆角占位)
|
||||
NSInteger count = MIN(4, titles.count);
|
||||
for (NSInteger i = 0; i < 4; i++) {
|
||||
KBTopImageButton *btn = self.featureButtons[i];
|
||||
if (i < count) {
|
||||
btn.textLabel.text = titles[i];
|
||||
}
|
||||
UIImage *img = (i < images.count) ? images[i] : nil;
|
||||
if (!img) {
|
||||
// 生成一张柔和的渐变占位图
|
||||
CGSize s = btn.iconSize;
|
||||
CGFloat cr = MIN(s.width, s.height) * 0.26;
|
||||
UIColor *c1 = [UIColor colorWithHex:0xC9F7E9];
|
||||
UIColor *c2 = [UIColor colorWithHex:0xA6E6FF];
|
||||
if (i == 1) { c1 = [UIColor colorWithHex:0xD7E5FF]; c2 = [UIColor colorWithHex:0xBFD2FF]; }
|
||||
if (i == 2) { c1 = [UIColor colorWithHex:0xEBD8FF]; c2 = [UIColor colorWithHex:0xDDBBFF]; }
|
||||
if (i == 3) { c1 = [UIColor colorWithHex:0xD1F5DE]; c2 = [UIColor colorWithHex:0xB6EBCE]; }
|
||||
img = [UIImage kb_gradientImageWithColors:@[c1, c2]
|
||||
locations:nil
|
||||
size:s
|
||||
direction:KBGradientDirectionLeftTopToRightBottom
|
||||
cornerRadius:cr];
|
||||
}
|
||||
btn.iconView.image = img;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Actions
|
||||
- (void)onTapBuyAction {
|
||||
if (self.onTapBuy) { self.onTapBuy(); }
|
||||
}
|
||||
|
||||
#pragma mark - Lazy
|
||||
- (UIImageView *)vipImageView{
|
||||
if (!_vipImageView) {
|
||||
_vipImageView = [[UIImageView alloc] init];
|
||||
_vipImageView.image = [UIImage imageNamed:@"home_vip_card"];
|
||||
_vipImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
_vipImageView.backgroundColor = [UIColor redColor];
|
||||
}
|
||||
return _vipImageView;
|
||||
}
|
||||
|
||||
- (UILabel *)titleLabel {
|
||||
if (!_titleLabel) {
|
||||
_titleLabel = [[UILabel alloc] init];
|
||||
_titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightBold];
|
||||
_titleLabel.textColor = [UIColor colorWithHex:0x1B1F1A];
|
||||
_titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
}
|
||||
return _titleLabel;
|
||||
}
|
||||
|
||||
- (UILabel *)subTitleLabel {
|
||||
if (!_subTitleLabel) {
|
||||
_subTitleLabel = [[UILabel alloc] init];
|
||||
_subTitleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
|
||||
_subTitleLabel.textColor = self.titleLabel.textColor;
|
||||
_subTitleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
}
|
||||
return _subTitleLabel;
|
||||
}
|
||||
|
||||
- (UIView *)featuresContainer {
|
||||
if (!_featuresContainer) {
|
||||
_featuresContainer = [[UIView alloc] init];
|
||||
// 不显式背景,保留父视图背景;如需调试可设置颜色
|
||||
// _featuresContainer.backgroundColor = [UIColor colorWithWhite:0 alpha:0.02];
|
||||
|
||||
// 创建4个功能按钮(懒加载一并放到数组)
|
||||
NSMutableArray *arr = [NSMutableArray arrayWithCapacity:4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
KBTopImageButton *btn = [[KBTopImageButton alloc] init];
|
||||
btn.iconSize = CGSizeMake(46, 46);
|
||||
btn.spacing = 5;
|
||||
[self.featuresContainer addSubview:btn];
|
||||
[arr addObject:btn];
|
||||
}
|
||||
_featureButtons = [arr copy];
|
||||
}
|
||||
return _featuresContainer;
|
||||
}
|
||||
|
||||
- (NSArray<KBTopImageButton *> *)featureButtons {
|
||||
// 只读访问,实际由 featuresContainer 的懒加载创建
|
||||
if (!_featureButtons) { (void)self.featuresContainer; }
|
||||
return _featureButtons;
|
||||
}
|
||||
|
||||
- (UIButton *)buyButton {
|
||||
if (!_buyButton) {
|
||||
_buyButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_buyButton setTitle:@"Recharge Now" forState:UIControlStateNormal];
|
||||
[_buyButton setTitleColor:[UIColor colorWithHex:0x1B1F1A] forState:UIControlStateNormal];
|
||||
_buyButton.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
|
||||
|
||||
[_buyButton addTarget:self action:@selector(onTapBuyAction) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _buyButton;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
}
|
||||
|
||||
- (PanModalHeight)shortFormHeight {
|
||||
return PanModalHeightMake(PanModalHeightTypeContent, self.minHeight ?: 300);
|
||||
return PanModalHeightMake(PanModalHeightTypeMaxTopInset, self.minHeight);
|
||||
}
|
||||
|
||||
- (PanModalHeight)longFormHeight {
|
||||
|
||||
25
keyBoard/Class/Home/V/KBTopImageButton.h
Normal file
25
keyBoard/Class/Home/V/KBTopImageButton.h
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// KBTopImageButton.h
|
||||
// keyBoard
|
||||
//
|
||||
// 上图下文按钮:支持自定义图标尺寸与上下间距
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface KBTopImageButton : UIControl
|
||||
/// 图标视图
|
||||
@property (nonatomic, strong, readonly) UIImageView *iconView;
|
||||
/// 文本标签
|
||||
@property (nonatomic, strong, readonly) UILabel *textLabel;
|
||||
/// 图片与文字之间的间距,默认 6
|
||||
@property (nonatomic, assign) CGFloat spacing;
|
||||
/// 图标尺寸,默认 44x44
|
||||
@property (nonatomic, assign) CGSize iconSize;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
61
keyBoard/Class/Home/V/KBTopImageButton.m
Normal file
61
keyBoard/Class/Home/V/KBTopImageButton.m
Normal file
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// KBTopImageButton.m
|
||||
// keyBoard
|
||||
//
|
||||
// 上图下文按钮:图片在上、文字在下,内部简单布局,适合图标型功能入口
|
||||
//
|
||||
|
||||
#import "KBTopImageButton.h"
|
||||
#import "UIColor+Extension.h"
|
||||
|
||||
@interface KBTopImageButton()
|
||||
@property (nonatomic, strong) UIImageView *iconView;
|
||||
@property (nonatomic, strong) UILabel *textLabel;
|
||||
@end
|
||||
|
||||
@implementation KBTopImageButton
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
_spacing = 6;
|
||||
_iconSize = CGSizeMake(44, 44);
|
||||
|
||||
_iconView = [[UIImageView alloc] init];
|
||||
_iconView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
[self addSubview:_iconView];
|
||||
|
||||
_textLabel = [[UILabel alloc] init];
|
||||
_textLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightSemibold];
|
||||
_textLabel.textColor = [UIColor colorWithHex:0x2B2B2B];
|
||||
_textLabel.textAlignment = NSTextAlignmentCenter;
|
||||
_textLabel.numberOfLines = 2;
|
||||
[self addSubview:_textLabel];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CGSize)intrinsicContentSize {
|
||||
CGFloat width = MAX(_iconSize.width, 60);
|
||||
return CGSizeMake(width, _iconSize.height + _spacing + 34);
|
||||
}
|
||||
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
CGFloat W = CGRectGetWidth(self.bounds);
|
||||
CGFloat H = CGRectGetHeight(self.bounds);
|
||||
CGSize iconS = self.iconSize;
|
||||
CGFloat ix = (W - iconS.width) * 0.5;
|
||||
self.iconView.frame = CGRectMake(ix, 0, iconS.width, iconS.height);
|
||||
|
||||
CGFloat labelTop = CGRectGetMaxY(self.iconView.frame) + self.spacing;
|
||||
CGFloat lh = MAX(0, H - labelTop);
|
||||
self.textLabel.frame = CGRectMake(0, labelTop, W, lh);
|
||||
}
|
||||
|
||||
- (void)setHighlighted:(BOOL)highlighted {
|
||||
[super setHighlighted:highlighted];
|
||||
self.alpha = highlighted ? 0.6 : 1.0;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -26,28 +26,28 @@
|
||||
[bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self.view);
|
||||
}];
|
||||
CGFloat topV = (500);
|
||||
// CGFloat topV = (500);
|
||||
|
||||
// [self.view addSubview:self.headView];
|
||||
// [self setupMas:topV];
|
||||
[self.view addSubview:self.headView];
|
||||
[self setupMas];
|
||||
// 创建sheetVC
|
||||
self.simplePanModalView = [[KBPanModalView alloc] init];
|
||||
// 使用宏,避免误写成函数指针判断导致恒为 true
|
||||
if (KB_DEVICE_HAS_NOTCH) {
|
||||
self.simplePanModalView.minHeight = KB_SCREEN_HEIGHT - topV - 34;
|
||||
self.simplePanModalView.minHeight = 473 - 44 + KB_NAV_TOTAL_HEIGHT;
|
||||
}else{
|
||||
self.simplePanModalView.minHeight = KB_SCREEN_HEIGHT - topV;
|
||||
self.simplePanModalView.minHeight = 473 - 44 + KB_NAV_TOTAL_HEIGHT;
|
||||
//
|
||||
}
|
||||
self.simplePanModalView.topInset = 100;
|
||||
[self.simplePanModalView presentInView:self.view];
|
||||
}
|
||||
|
||||
- (void)setupMas:(CGFloat)headViewTopV{
|
||||
- (void)setupMas{
|
||||
[self.headView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.equalTo(self.view);
|
||||
make.top.equalTo(self.view);
|
||||
make.height.mas_equalTo(headViewTopV);
|
||||
make.top.equalTo(self.view).offset(KB_NAV_TOTAL_HEIGHT);
|
||||
make.height.mas_equalTo(473 - 44);
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user