修改我界面顶部我的键盘和设置按钮布局
This commit is contained in:
@@ -5,12 +5,12 @@
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "my_kb_icon@2x.png",
|
||||
"filename" : "切图 299@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "my_kb_icon@3x.png",
|
||||
"filename" : "切图 299@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 453 B |
Binary file not shown.
|
Before Width: | Height: | Size: 657 B |
BIN
keyBoard/Assets.xcassets/My/my_kb_icon.imageset/切图 299@2x.png
vendored
Normal file
BIN
keyBoard/Assets.xcassets/My/my_kb_icon.imageset/切图 299@2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 900 B |
BIN
keyBoard/Assets.xcassets/My/my_kb_icon.imageset/切图 299@3x.png
vendored
Normal file
BIN
keyBoard/Assets.xcassets/My/my_kb_icon.imageset/切图 299@3x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
22
keyBoard/Assets.xcassets/My/my_setting_icon.imageset/Contents.json
vendored
Normal file
22
keyBoard/Assets.xcassets/My/my_setting_icon.imageset/Contents.json
vendored
Normal 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
|
||||
}
|
||||
}
|
||||
BIN
keyBoard/Assets.xcassets/My/my_setting_icon.imageset/切图 300@2x.png
vendored
Normal file
BIN
keyBoard/Assets.xcassets/My/my_setting_icon.imageset/切图 300@2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
keyBoard/Assets.xcassets/My/my_setting_icon.imageset/切图 300@3x.png
vendored
Normal file
BIN
keyBoard/Assets.xcassets/My/my_setting_icon.imageset/切图 300@3x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
@@ -16,13 +16,14 @@
|
||||
@interface KBMyHeaderView ()
|
||||
@property (nonatomic, strong) UILabel *titleLabel;
|
||||
@property (nonatomic, strong) UIButton *keyboardBtn;
|
||||
@property (nonatomic, strong) UIButton *settingBtn;
|
||||
@property (nonatomic, strong) UIImageView *avatarView;
|
||||
@property (nonatomic, strong) UILabel *nameLabel;
|
||||
@property (nonatomic, strong) UIImageView *vipIconView;
|
||||
@property (nonatomic, strong) UILabel *vipExpiryLabel;
|
||||
@property (nonatomic, strong) UIImageView *cardLeft;
|
||||
@property (nonatomic, strong) UIImageView *cardRight;
|
||||
@property (nonatomic, strong) UIImageView *avatarEditIcon; // 头像右下角的编辑图标
|
||||
//@property (nonatomic, strong) UIImageView *avatarEditIcon; // 头像右下角的编辑图标
|
||||
@property (nonatomic, strong) KBUser *userModel;
|
||||
@property (nonatomic, assign) NSInteger kb_vipLayoutState; // -1: unknown, 0: non-vip, 1: vip
|
||||
//@property (nonatomic, strong) MASConstraint *vipIconWidthConstraint;
|
||||
@@ -40,8 +41,9 @@
|
||||
|
||||
[self addSubview:self.titleLabel];
|
||||
[self addSubview:self.keyboardBtn];
|
||||
[self addSubview:self.settingBtn];
|
||||
[self addSubview:self.avatarView];
|
||||
[self addSubview:self.avatarEditIcon]; // 头像右下角编辑图标
|
||||
// [self addSubview:self.avatarEditIcon]; // 头像右下角编辑图标
|
||||
[self addSubview:self.nameLabel];
|
||||
[self addSubview:self.vipIconView];
|
||||
[self addSubview:self.vipExpiryLabel];
|
||||
@@ -53,22 +55,28 @@
|
||||
make.left.equalTo(self).offset(26);
|
||||
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) {
|
||||
make.centerY.equalTo(self.titleLabel);
|
||||
make.right.equalTo(self).offset(-20);
|
||||
make.height.mas_equalTo(34);
|
||||
make.width.mas_greaterThanOrEqualTo(90);
|
||||
make.right.equalTo(self.settingBtn.mas_left).offset(-18);
|
||||
make.height.mas_equalTo(20);
|
||||
make.width.mas_equalTo(27);
|
||||
}];
|
||||
[self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self).offset(26);
|
||||
make.bottom.equalTo(self.cardLeft.mas_top).offset(-23);
|
||||
make.width.height.mas_equalTo(70);
|
||||
}];
|
||||
[self.avatarEditIcon mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.height.mas_equalTo(18);
|
||||
make.right.equalTo(self.avatarView.mas_right);
|
||||
make.bottom.equalTo(self.avatarView.mas_bottom);
|
||||
}];
|
||||
// [self.avatarEditIcon mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.width.height.mas_equalTo(18);
|
||||
// make.right.equalTo(self.avatarView.mas_right);
|
||||
// make.bottom.equalTo(self.avatarView.mas_bottom);
|
||||
// }];
|
||||
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.avatarView.mas_right).offset(10);
|
||||
make.bottom.equalTo(self.avatarView.mas_centerY).offset(-4);
|
||||
@@ -261,45 +269,33 @@
|
||||
- (UIButton *)keyboardBtn {
|
||||
if (!_keyboardBtn) {
|
||||
_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"];
|
||||
if (kbImg) {
|
||||
[_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 setImage:kbImg forState:UIControlStateNormal];
|
||||
// 点击事件
|
||||
[_keyboardBtn addTarget:self action:@selector(onKeyboardTap) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
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 {
|
||||
if (!_avatarView) {
|
||||
_avatarView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"lufei.jpg"]];
|
||||
_avatarView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
_avatarView.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0];
|
||||
_avatarView.userInteractionEnabled = YES; // 头像可点击
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onAvatarTap)];
|
||||
[_avatarView addGestureRecognizer:tap];
|
||||
// UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onAvatarTap)];
|
||||
// [_avatarView addGestureRecognizer:tap];
|
||||
}
|
||||
return _avatarView;
|
||||
}
|
||||
@@ -365,25 +361,31 @@
|
||||
return _cardRight;
|
||||
}
|
||||
|
||||
- (UIImageView *)avatarEditIcon {
|
||||
if (!_avatarEditIcon) {
|
||||
_avatarEditIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"my_head_edite"]];
|
||||
_avatarEditIcon.contentMode = UIViewContentModeScaleAspectFit;
|
||||
_avatarEditIcon.userInteractionEnabled = NO; // 仅展示
|
||||
}
|
||||
return _avatarEditIcon;
|
||||
}
|
||||
//- (UIImageView *)avatarEditIcon {
|
||||
// if (!_avatarEditIcon) {
|
||||
// _avatarEditIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"my_head_edite"]];
|
||||
// _avatarEditIcon.contentMode = UIViewContentModeScaleAspectFit;
|
||||
// _avatarEditIcon.userInteractionEnabled = NO; // 仅展示
|
||||
// }
|
||||
// return _avatarEditIcon;
|
||||
//}
|
||||
|
||||
#pragma mark - Actions
|
||||
- (void)onKeyboardTap {
|
||||
KBMyKeyBoardVC *vc = [[KBMyKeyBoardVC alloc] init];
|
||||
[KB_CURRENT_NAV pushViewController:vc animated:true];
|
||||
}
|
||||
- (void)onAvatarTap {
|
||||
|
||||
- (void)settingBtnTap{
|
||||
KBPersonInfoVC *vc = [[KBPersonInfoVC alloc] init];
|
||||
// vc.userModel = self.userModel;
|
||||
[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 {
|
||||
KBPayMainVC *vc = [[KBPayMainVC alloc] init];
|
||||
[KB_CURRENT_NAV pushViewController:vc animated:true];
|
||||
|
||||
Reference in New Issue
Block a user