1
This commit is contained in:
@@ -44,7 +44,7 @@
|
||||
make.centerY.equalTo(self.titleLabel);
|
||||
make.right.equalTo(self).offset(-20);
|
||||
make.height.mas_equalTo(34);
|
||||
make.width.mas_greaterThanOrEqualTo(110);
|
||||
make.width.mas_greaterThanOrEqualTo(90);
|
||||
}];
|
||||
[self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self).offset(26);
|
||||
@@ -124,14 +124,22 @@
|
||||
_keyboardBtn.layer.cornerRadius = 17;
|
||||
_keyboardBtn.layer.masksToBounds = YES;
|
||||
|
||||
// 图标 + 文本,图文间距 6
|
||||
// 图标 + 文本,保持不同语言下左右内边距一致
|
||||
UIImage *kbImg = [UIImage imageNamed:@"my_kb_icon"];
|
||||
if (kbImg) {
|
||||
[_keyboardBtn setImage:kbImg forState:UIControlStateNormal];
|
||||
_keyboardBtn.imageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
CGFloat spacing = 3.0;
|
||||
_keyboardBtn.contentEdgeInsets = UIEdgeInsetsMake(0, spacing, 0, spacing);
|
||||
_keyboardBtn.titleEdgeInsets = UIEdgeInsetsMake(0, spacing, 0, -spacing);
|
||||
// 按钮左右内边距(与文字无关,始终生效)
|
||||
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];
|
||||
}
|
||||
|
||||
// 点击事件
|
||||
|
||||
Reference in New Issue
Block a user