1
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
|
||||
|
||||
@interface HomeHeadView()
|
||||
@property (nonatomic, strong) UIImageView *loveKeyImageView;
|
||||
|
||||
// 顶部会员卡图片
|
||||
@property (nonatomic, strong) UIImageView *vipImageView;
|
||||
// 主/副标题
|
||||
@@ -43,6 +45,7 @@
|
||||
|
||||
#pragma mark - UI
|
||||
- (void)setupViews {
|
||||
// [self addSubview:self.loveKeyImageView];
|
||||
[self addSubview:self.vipImageView];
|
||||
[self addSubview:self.titleLabel];
|
||||
[self addSubview:self.subTitleLabel];
|
||||
@@ -58,6 +61,13 @@
|
||||
make.width.mas_equalTo(217);
|
||||
make.height.mas_equalTo(166);
|
||||
}];
|
||||
|
||||
// [self.loveKeyImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.top.equalTo(self.vipImageView.mas_centerY).offset(0);
|
||||
// make.right.equalTo(self).offset(-16);
|
||||
// make.width.mas_equalTo(335);
|
||||
// make.height.mas_equalTo(117);
|
||||
// }];
|
||||
|
||||
// 主标题
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
@@ -82,7 +92,7 @@
|
||||
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);
|
||||
make.height.mas_equalTo(80);
|
||||
}];
|
||||
|
||||
// 四个按钮等宽分布
|
||||
@@ -128,7 +138,11 @@
|
||||
@"Personalized\nKeyboard",
|
||||
@"Chat\nPersona",
|
||||
@"Emotional\nCounseling"];
|
||||
[self configureFeatureTitles:titles images:nil];
|
||||
NSArray *images = @[[UIImage imageNamed:@"home_ai_icon"],
|
||||
[UIImage imageNamed:@"home_keyboard_icon"],
|
||||
[UIImage imageNamed:@"home_chat_icon"],
|
||||
[UIImage imageNamed:@"home_emotion_icon"]];
|
||||
[self configureFeatureTitles:titles images:images];
|
||||
}
|
||||
|
||||
#pragma mark - Public
|
||||
@@ -141,21 +155,6 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -169,12 +168,19 @@
|
||||
- (UIImageView *)vipImageView{
|
||||
if (!_vipImageView) {
|
||||
_vipImageView = [[UIImageView alloc] init];
|
||||
_vipImageView.image = [UIImage imageNamed:@"home_vip_card"];
|
||||
_vipImageView.image = [UIImage imageNamed:@"home_topvip_icon"];
|
||||
_vipImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
_vipImageView.backgroundColor = [UIColor redColor];
|
||||
}
|
||||
return _vipImageView;
|
||||
}
|
||||
- (UIImageView *)loveKeyImageView{
|
||||
if (!_loveKeyImageView) {
|
||||
_loveKeyImageView = [[UIImageView alloc] init];
|
||||
_loveKeyImageView.image = [UIImage imageNamed:@"hoem_love_key"];
|
||||
_loveKeyImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
}
|
||||
return _loveKeyImageView;
|
||||
}
|
||||
|
||||
- (UILabel *)titleLabel {
|
||||
if (!_titleLabel) {
|
||||
@@ -206,8 +212,8 @@
|
||||
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;
|
||||
btn.iconSize = CGSizeMake(54, 44);
|
||||
btn.spacing = 0;
|
||||
[self.featuresContainer addSubview:btn];
|
||||
[arr addObject:btn];
|
||||
}
|
||||
|
||||
@@ -39,14 +39,14 @@
|
||||
[self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.rankLabel.mas_right).offset(12);
|
||||
make.centerY.equalTo(self.contentView);
|
||||
make.width.height.mas_equalTo(52);
|
||||
make.width.height.mas_equalTo(56);
|
||||
}];
|
||||
|
||||
[self.actionButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.equalTo(self.contentView);
|
||||
make.right.equalTo(self.contentView).offset(-16);
|
||||
make.width.mas_equalTo(64);
|
||||
make.height.mas_equalTo(36);
|
||||
make.width.mas_equalTo(56);
|
||||
make.height.mas_equalTo(38);
|
||||
}];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
@@ -104,8 +104,8 @@
|
||||
- (UILabel *)titleLabel {
|
||||
if (!_titleLabel) {
|
||||
_titleLabel = [[UILabel alloc] init];
|
||||
_titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightSemibold];
|
||||
_titleLabel.textColor = [UIColor colorWithWhite:0.1 alpha:1];
|
||||
_titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
|
||||
_titleLabel.textColor = [UIColor colorWithHex:0x1B1F1A];
|
||||
}
|
||||
return _titleLabel;
|
||||
}
|
||||
@@ -113,9 +113,9 @@
|
||||
- (UILabel *)subLabel {
|
||||
if (!_subLabel) {
|
||||
_subLabel = [[UILabel alloc] init];
|
||||
_subLabel.font = [UIFont systemFontOfSize:13];
|
||||
_subLabel.textColor = [UIColor colorWithWhite:0.5 alpha:1];
|
||||
_subLabel.numberOfLines = 1;
|
||||
_subLabel.font = [UIFont systemFontOfSize:12];
|
||||
_subLabel.textColor = [UIColor colorWithHex:0x9A9A9A];
|
||||
_subLabel.numberOfLines = 2;
|
||||
}
|
||||
return _subLabel;
|
||||
}
|
||||
@@ -123,7 +123,7 @@
|
||||
- (UIButton *)actionButton {
|
||||
if (!_actionButton) {
|
||||
_actionButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
_actionButton.layer.cornerRadius = 18;
|
||||
_actionButton.layer.cornerRadius = 12;
|
||||
_actionButton.layer.masksToBounds = YES;
|
||||
_actionButton.titleLabel.font = [UIFont systemFontOfSize:20 weight:UIFontWeightBold];
|
||||
}
|
||||
|
||||
@@ -45,7 +45,8 @@
|
||||
// 该背景色会被 HWPanModal 用来设置容器的 _contentView 背景色
|
||||
// 参考 Pods/HWPanModal/Sources/View/PanModal/HWPanModalContainerView.m: adjustPanContainerBackgroundColor
|
||||
// 想要改变外层白色底(截图中 _contentView)的颜色,只需改这里即可
|
||||
self.backgroundColor = [UIColor colorWithHex:0xE8FFF4]; // 柔和的绿色
|
||||
// self.backgroundColor = [UIColor colorWithHex:0xE8FFF4]; // 柔和的绿色
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
// HWBackgroundConfig *config = [HWBackgroundConfig configWithBehavior:HWBackgroundBehaviorDefault];
|
||||
// config.backgroundAlpha = 0;
|
||||
// [self.hw_dimmedView reloadConfig:config];
|
||||
@@ -180,11 +181,11 @@
|
||||
|
||||
[self.leftBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.top.equalTo(self.secWhiteContentView);
|
||||
make.bottom.equalTo(self.secWhiteContentView);
|
||||
// make.bottom.equalTo(self.secWhiteContentView);
|
||||
}];
|
||||
[self.rightBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.top.equalTo(self.secWhiteContentView);
|
||||
make.bottom.equalTo(self.secWhiteContentView);
|
||||
// make.bottom.equalTo(self.secWhiteContentView);
|
||||
}];
|
||||
|
||||
|
||||
@@ -231,7 +232,7 @@
|
||||
[self.topBar addSubview:self.underlineImageView];
|
||||
|
||||
// Masonry 约束
|
||||
CGFloat topPadding = 0; // 与顶部小指示器留点空间
|
||||
CGFloat topPadding = 12; // 与顶部小指示器留点空间
|
||||
[self.topBar mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.equalTo(self.secWhiteContentView);
|
||||
make.top.equalTo(self.secWhiteContentView).offset(topPadding);
|
||||
@@ -259,14 +260,14 @@
|
||||
|
||||
[self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.topBar.mas_bottom).offset(8);
|
||||
make.left.right.equalTo(self.secWhiteContentView).inset(16);
|
||||
make.left.right.equalTo(self.secWhiteContentView).inset(20);
|
||||
make.bottom.equalTo(self.secWhiteContentView);
|
||||
}];
|
||||
|
||||
[self.personImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// 仍按页面整体的左右边距定位,保持与改层级前的视觉一致
|
||||
make.left.equalTo(self).offset(46);
|
||||
make.bottom.equalTo(self.topBar.mas_top).offset(20);
|
||||
make.bottom.equalTo(self.topBar.mas_top).offset(11);
|
||||
make.width.mas_equalTo(53);
|
||||
make.height.mas_equalTo(81);
|
||||
}];
|
||||
@@ -283,7 +284,7 @@
|
||||
#pragma mark - Action
|
||||
|
||||
- (void)onTapTopButton:(UIButton *)sender {
|
||||
[self switchToIndex:sender.tag animated:YES];
|
||||
[self switchToIndex:sender.tag animated:false];
|
||||
// [self hw_panModalSetNeedsLayoutUpdate];
|
||||
}
|
||||
|
||||
@@ -318,7 +319,6 @@
|
||||
// 添加目标
|
||||
// [self addChildViewController:target];
|
||||
[self.containerView addSubview:target.view];
|
||||
target.view.backgroundColor = [UIColor colorWithWhite:0.98 alpha:1];
|
||||
[target.view mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.top.right.equalTo(self.containerView);
|
||||
make.bottom.equalTo(self.containerView).offset(-KB_TABBAR_HEIGHT);
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
[self.cardImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.avatarCircleView.mas_bottom).offset(-34); // 顶部悬浮重叠
|
||||
make.left.right.equalTo(self);
|
||||
make.height.mas_equalTo(KBFit(148));
|
||||
make.height.mas_equalTo(KBFit(158));
|
||||
}];
|
||||
|
||||
|
||||
@@ -129,6 +129,9 @@
|
||||
@property (nonatomic, strong) KBTopThreeCardView *rightCard;
|
||||
/// 统一的底部加号按钮(移出卡片,放到 KBTopThreeView)
|
||||
@property (nonatomic, strong) UIButton *plusButton;
|
||||
/// 左右卡片底部也有 plus 按钮
|
||||
@property (nonatomic, strong) UIButton *leftPlusButton;
|
||||
@property (nonatomic, strong) UIButton *rightPlusButton;
|
||||
@end
|
||||
|
||||
@implementation KBTopThreeView
|
||||
@@ -146,6 +149,8 @@
|
||||
[self addSubview:self.centerCard];
|
||||
[self addSubview:self.rightCard];
|
||||
[self addSubview:self.plusButton];
|
||||
[self addSubview:self.leftPlusButton];
|
||||
[self addSubview:self.rightPlusButton];
|
||||
|
||||
// 横向均分布局
|
||||
[self.centerCard mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
@@ -173,11 +178,25 @@
|
||||
// 用 plusButton 来“撑起”本视图,且底部对齐
|
||||
[self.plusButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.centerCard.mas_bottom).offset(12);
|
||||
make.centerX.equalTo(self);
|
||||
make.width.mas_equalTo(52);
|
||||
make.centerX.equalTo(self); // 或改为 equalTo(self.centerCard) 以严格与中卡居中
|
||||
make.width.mas_equalTo(60);
|
||||
make.height.mas_equalTo(28);
|
||||
make.bottom.equalTo(self).offset(-8);
|
||||
}];
|
||||
|
||||
// 左右 plus 按钮,同样底部对齐,用它们一起撑起视图
|
||||
[self.leftPlusButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.leftCard.mas_bottom).offset(12);
|
||||
make.centerX.equalTo(self.leftCard);
|
||||
make.width.height.equalTo(self.plusButton);
|
||||
make.bottom.equalTo(self).offset(-8);
|
||||
}];
|
||||
[self.rightPlusButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.rightCard.mas_bottom).offset(12);
|
||||
make.centerX.equalTo(self.rightCard);
|
||||
make.width.height.equalTo(self.plusButton);
|
||||
make.bottom.equalTo(self).offset(-8);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)configWithItems:(NSArray<NSDictionary *> *)items {
|
||||
@@ -214,4 +233,30 @@
|
||||
return _plusButton;
|
||||
}
|
||||
|
||||
- (UIButton *)leftPlusButton {
|
||||
if (!_leftPlusButton) {
|
||||
_leftPlusButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_leftPlusButton setTitle:@"+" forState:UIControlStateNormal];
|
||||
[_leftPlusButton setTitleColor:[UIColor colorWithRed:0.20 green:0.65 blue:0.50 alpha:1.0] forState:UIControlStateNormal];
|
||||
_leftPlusButton.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightSemibold];
|
||||
_leftPlusButton.layer.cornerRadius = 14.0;
|
||||
_leftPlusButton.layer.masksToBounds = YES;
|
||||
_leftPlusButton.backgroundColor = [[UIColor colorWithRed:0.20 green:0.65 blue:0.50 alpha:1.0] colorWithAlphaComponent:0.15];
|
||||
}
|
||||
return _leftPlusButton;
|
||||
}
|
||||
|
||||
- (UIButton *)rightPlusButton {
|
||||
if (!_rightPlusButton) {
|
||||
_rightPlusButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_rightPlusButton setTitle:@"+" forState:UIControlStateNormal];
|
||||
[_rightPlusButton setTitleColor:[UIColor colorWithRed:0.20 green:0.65 blue:0.50 alpha:1.0] forState:UIControlStateNormal];
|
||||
_rightPlusButton.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightSemibold];
|
||||
_rightPlusButton.layer.cornerRadius = 14.0;
|
||||
_rightPlusButton.layer.masksToBounds = YES;
|
||||
_rightPlusButton.backgroundColor = [[UIColor colorWithRed:0.20 green:0.65 blue:0.50 alpha:1.0] colorWithAlphaComponent:0.15];
|
||||
}
|
||||
return _rightPlusButton;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user