修改我界面顶部我的键盘和设置按钮布局

This commit is contained in:
2026-03-05 19:46:22 +08:00
parent d25dd38959
commit 3c18579a83
9 changed files with 72 additions and 48 deletions

View File

@@ -5,12 +5,12 @@
"scale" : "1x" "scale" : "1x"
}, },
{ {
"filename" : "my_kb_icon@2x.png", "filename" : "切图 299@2x.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "2x" "scale" : "2x"
}, },
{ {
"filename" : "my_kb_icon@3x.png", "filename" : "切图 299@3x.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "3x" "scale" : "3x"
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 453 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 657 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "切图 300@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "切图 300@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@@ -16,13 +16,14 @@
@interface KBMyHeaderView () @interface KBMyHeaderView ()
@property (nonatomic, strong) UILabel *titleLabel; @property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIButton *keyboardBtn; @property (nonatomic, strong) UIButton *keyboardBtn;
@property (nonatomic, strong) UIButton *settingBtn;
@property (nonatomic, strong) UIImageView *avatarView; @property (nonatomic, strong) UIImageView *avatarView;
@property (nonatomic, strong) UILabel *nameLabel; @property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UIImageView *vipIconView; @property (nonatomic, strong) UIImageView *vipIconView;
@property (nonatomic, strong) UILabel *vipExpiryLabel; @property (nonatomic, strong) UILabel *vipExpiryLabel;
@property (nonatomic, strong) UIImageView *cardLeft; @property (nonatomic, strong) UIImageView *cardLeft;
@property (nonatomic, strong) UIImageView *cardRight; @property (nonatomic, strong) UIImageView *cardRight;
@property (nonatomic, strong) UIImageView *avatarEditIcon; // //@property (nonatomic, strong) UIImageView *avatarEditIcon; //
@property (nonatomic, strong) KBUser *userModel; @property (nonatomic, strong) KBUser *userModel;
@property (nonatomic, assign) NSInteger kb_vipLayoutState; // -1: unknown, 0: non-vip, 1: vip @property (nonatomic, assign) NSInteger kb_vipLayoutState; // -1: unknown, 0: non-vip, 1: vip
//@property (nonatomic, strong) MASConstraint *vipIconWidthConstraint; //@property (nonatomic, strong) MASConstraint *vipIconWidthConstraint;
@@ -40,8 +41,9 @@
[self addSubview:self.titleLabel]; [self addSubview:self.titleLabel];
[self addSubview:self.keyboardBtn]; [self addSubview:self.keyboardBtn];
[self addSubview:self.settingBtn];
[self addSubview:self.avatarView]; [self addSubview:self.avatarView];
[self addSubview:self.avatarEditIcon]; // // [self addSubview:self.avatarEditIcon]; //
[self addSubview:self.nameLabel]; [self addSubview:self.nameLabel];
[self addSubview:self.vipIconView]; [self addSubview:self.vipIconView];
[self addSubview:self.vipExpiryLabel]; [self addSubview:self.vipExpiryLabel];
@@ -53,22 +55,28 @@
make.left.equalTo(self).offset(26); make.left.equalTo(self).offset(26);
make.bottom.equalTo(self.avatarView.mas_top).offset(-35); // make.bottom.equalTo(self.avatarView.mas_top).offset(-35); //
}]; }];
[self.settingBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.titleLabel);
make.right.equalTo(self).offset(-16);
make.height.mas_equalTo(20);
make.width.mas_equalTo(22);
}];
[self.keyboardBtn mas_makeConstraints:^(MASConstraintMaker *make) { [self.keyboardBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.titleLabel); make.centerY.equalTo(self.titleLabel);
make.right.equalTo(self).offset(-20); make.right.equalTo(self.settingBtn.mas_left).offset(-18);
make.height.mas_equalTo(34); make.height.mas_equalTo(20);
make.width.mas_greaterThanOrEqualTo(90); make.width.mas_equalTo(27);
}]; }];
[self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) { [self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).offset(26); make.left.equalTo(self).offset(26);
make.bottom.equalTo(self.cardLeft.mas_top).offset(-23); make.bottom.equalTo(self.cardLeft.mas_top).offset(-23);
make.width.height.mas_equalTo(70); make.width.height.mas_equalTo(70);
}]; }];
[self.avatarEditIcon mas_makeConstraints:^(MASConstraintMaker *make) { // [self.avatarEditIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(18); // make.width.height.mas_equalTo(18);
make.right.equalTo(self.avatarView.mas_right); // make.right.equalTo(self.avatarView.mas_right);
make.bottom.equalTo(self.avatarView.mas_bottom); // make.bottom.equalTo(self.avatarView.mas_bottom);
}]; // }];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) { [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.avatarView.mas_right).offset(10); make.left.equalTo(self.avatarView.mas_right).offset(10);
make.bottom.equalTo(self.avatarView.mas_centerY).offset(-4); make.bottom.equalTo(self.avatarView.mas_centerY).offset(-4);
@@ -261,45 +269,33 @@
- (UIButton *)keyboardBtn { - (UIButton *)keyboardBtn {
if (!_keyboardBtn) { if (!_keyboardBtn) {
_keyboardBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _keyboardBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_keyboardBtn setTitle:KBLocalized(@"My Keyboard") forState:UIControlStateNormal];
_keyboardBtn.titleLabel.font = [KBFont medium:10];
[_keyboardBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
_keyboardBtn.backgroundColor = [UIColor colorWithHex:KBColorValue];
_keyboardBtn.layer.cornerRadius = 17;
_keyboardBtn.layer.masksToBounds = YES;
// +
UIImage *kbImg = [UIImage imageNamed:@"my_kb_icon"]; UIImage *kbImg = [UIImage imageNamed:@"my_kb_icon"];
if (kbImg) {
[_keyboardBtn setImage:kbImg forState:UIControlStateNormal]; [_keyboardBtn setImage:kbImg forState:UIControlStateNormal];
_keyboardBtn.imageView.contentMode = UIViewContentModeScaleAspectFit;
//
CGFloat horizontalPadding = 10.0;
_keyboardBtn.contentEdgeInsets = UIEdgeInsetsMake(0, horizontalPadding, 0, horizontalPadding);
//
CGFloat spacing = 6.0;
_keyboardBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -spacing / 2.0, 0, spacing / 2.0);
_keyboardBtn.titleEdgeInsets = UIEdgeInsetsMake(0, spacing / 2.0, 0, -spacing / 2.0);
//
[_keyboardBtn setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
[_keyboardBtn setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
}
// //
[_keyboardBtn addTarget:self action:@selector(onKeyboardTap) forControlEvents:UIControlEventTouchUpInside]; [_keyboardBtn addTarget:self action:@selector(onKeyboardTap) forControlEvents:UIControlEventTouchUpInside];
} }
return _keyboardBtn; return _keyboardBtn;
} }
- (UIButton *)settingBtn {
if (!_settingBtn) {
_settingBtn = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *kbImg = [UIImage imageNamed:@"my_setting_icon"];
[_settingBtn setImage:kbImg forState:UIControlStateNormal];
//
[_settingBtn addTarget:self action:@selector(settingBtnTap) forControlEvents:UIControlEventTouchUpInside];
}
return _settingBtn;
}
- (UIImageView *)avatarView { - (UIImageView *)avatarView {
if (!_avatarView) { if (!_avatarView) {
_avatarView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"lufei.jpg"]]; _avatarView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"lufei.jpg"]];
_avatarView.contentMode = UIViewContentModeScaleAspectFill; _avatarView.contentMode = UIViewContentModeScaleAspectFill;
_avatarView.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0]; _avatarView.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0];
_avatarView.userInteractionEnabled = YES; // _avatarView.userInteractionEnabled = YES; //
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onAvatarTap)]; // UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onAvatarTap)];
[_avatarView addGestureRecognizer:tap]; // [_avatarView addGestureRecognizer:tap];
} }
return _avatarView; return _avatarView;
} }
@@ -365,25 +361,31 @@
return _cardRight; return _cardRight;
} }
- (UIImageView *)avatarEditIcon { //- (UIImageView *)avatarEditIcon {
if (!_avatarEditIcon) { // if (!_avatarEditIcon) {
_avatarEditIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"my_head_edite"]]; // _avatarEditIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"my_head_edite"]];
_avatarEditIcon.contentMode = UIViewContentModeScaleAspectFit; // _avatarEditIcon.contentMode = UIViewContentModeScaleAspectFit;
_avatarEditIcon.userInteractionEnabled = NO; // // _avatarEditIcon.userInteractionEnabled = NO; //
} // }
return _avatarEditIcon; // return _avatarEditIcon;
} //}
#pragma mark - Actions #pragma mark - Actions
- (void)onKeyboardTap { - (void)onKeyboardTap {
KBMyKeyBoardVC *vc = [[KBMyKeyBoardVC alloc] init]; KBMyKeyBoardVC *vc = [[KBMyKeyBoardVC alloc] init];
[KB_CURRENT_NAV pushViewController:vc animated:true]; [KB_CURRENT_NAV pushViewController:vc animated:true];
} }
- (void)onAvatarTap {
- (void)settingBtnTap{
KBPersonInfoVC *vc = [[KBPersonInfoVC alloc] init]; KBPersonInfoVC *vc = [[KBPersonInfoVC alloc] init];
// vc.userModel = self.userModel;
[KB_CURRENT_NAV pushViewController:vc animated:true]; [KB_CURRENT_NAV pushViewController:vc animated:true];
} }
- (void)onAvatarTap {
// KBPersonInfoVC *vc = [[KBPersonInfoVC alloc] init];
//// vc.userModel = self.userModel;
// [KB_CURRENT_NAV pushViewController:vc animated:true];
}
- (void)onLeftCardTap { - (void)onLeftCardTap {
KBPayMainVC *vc = [[KBPayMainVC alloc] init]; KBPayMainVC *vc = [[KBPayMainVC alloc] init];
[KB_CURRENT_NAV pushViewController:vc animated:true]; [KB_CURRENT_NAV pushViewController:vc animated:true];