fix ui
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
// 复制按钮
|
||||
@property (nonatomic, strong) UIButton *copyBtn;
|
||||
// 分割线
|
||||
@property (nonatomic, strong) UIView *line;
|
||||
// 废弃分割线:按需求不显示底部分割线
|
||||
// 记录圆角位置,layoutSubviews 时更新 mask
|
||||
@property (nonatomic, assign) UIRectCorner cornerRecord;
|
||||
@end
|
||||
@@ -38,7 +38,6 @@
|
||||
[self.cardView addSubview:self.valueLabel];
|
||||
[self.cardView addSubview:self.arrowView];
|
||||
[self.cardView addSubview:self.copyBtn];
|
||||
[self.cardView addSubview:self.line];
|
||||
|
||||
[self.cardView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.contentView).offset(16);
|
||||
@@ -70,20 +69,15 @@
|
||||
make.right.equalTo(self.arrowView.mas_left).offset(-8);
|
||||
}];
|
||||
|
||||
[self.line mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.cardView).offset(16);
|
||||
make.right.equalTo(self.cardView).offset(-16);
|
||||
make.bottom.equalTo(self.cardView);
|
||||
make.height.mas_equalTo(0.5);
|
||||
}];
|
||||
// 不添加底部分割线
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
// 卡片圆角半径保持一致
|
||||
self.cardView.layer.cornerRadius = 12.0;
|
||||
// 根据位置设置圆角:顶部或底部为 12,中间为 0
|
||||
self.cardView.layer.cornerRadius = (self.cornerRecord != 0 ? 12.0 : 0.0);
|
||||
// 根据记录的 corner 重新生成 mask,保证尺寸变化后仍正确
|
||||
if (self.cornerRecord != 0 && !CGRectIsEmpty(self.cardView.bounds)) {
|
||||
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.cardView.bounds
|
||||
@@ -100,7 +94,6 @@
|
||||
- (void)prepareForReuse {
|
||||
[super prepareForReuse];
|
||||
self.arrowView.hidden = YES; self.copyBtn.hidden = YES;
|
||||
self.line.hidden = NO;
|
||||
}
|
||||
|
||||
- (void)configWithTitle:(NSString *)title
|
||||
@@ -126,15 +119,12 @@
|
||||
UIRectCorner corners = 0;
|
||||
if (isTop && isBottom) {
|
||||
corners = UIRectCornerAllCorners;
|
||||
self.line.hidden = YES;
|
||||
} else if (isTop) {
|
||||
corners = UIRectCornerTopLeft | UIRectCornerTopRight;
|
||||
self.line.hidden = NO;
|
||||
} else if (isBottom) {
|
||||
corners = UIRectCornerBottomLeft | UIRectCornerBottomRight;
|
||||
self.line.hidden = YES; // 底部不需要分割线
|
||||
} else {
|
||||
corners = 0; self.line.hidden = NO;
|
||||
corners = 0;
|
||||
}
|
||||
|
||||
// 使用遮罩实现指定圆角
|
||||
@@ -149,7 +139,7 @@
|
||||
if (!_cardView) {
|
||||
_cardView = [UIView new];
|
||||
_cardView.backgroundColor = UIColor.whiteColor;
|
||||
_cardView.layer.cornerRadius = 12.0;
|
||||
_cardView.layer.cornerRadius = 0.0; // 具体圆角在 layoutSubviews 中按位置设置
|
||||
_cardView.layer.masksToBounds = YES; // 配合圆角
|
||||
}
|
||||
return _cardView;
|
||||
@@ -158,7 +148,7 @@
|
||||
- (UILabel *)titleLabel {
|
||||
if (!_titleLabel) {
|
||||
_titleLabel = [UILabel new];
|
||||
_titleLabel.textColor = [UIColor colorWithWhite:0.2 alpha:1.0];
|
||||
_titleLabel.textColor = [UIColor colorWithHex:KBBlackValue];
|
||||
_titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightRegular];
|
||||
}
|
||||
return _titleLabel;
|
||||
@@ -167,7 +157,7 @@
|
||||
- (UILabel *)valueLabel {
|
||||
if (!_valueLabel) {
|
||||
_valueLabel = [UILabel new];
|
||||
_valueLabel.textColor = [UIColor blackColor];
|
||||
_valueLabel.textColor = [UIColor colorWithHex:KBBlackValue];
|
||||
_valueLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
|
||||
_valueLabel.textAlignment = NSTextAlignmentRight;
|
||||
[_valueLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
||||
@@ -230,13 +220,7 @@
|
||||
return _copyBtn;
|
||||
}
|
||||
|
||||
- (UIView *)line {
|
||||
if (!_line) {
|
||||
_line = [UIView new];
|
||||
_line.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0];
|
||||
}
|
||||
return _line;
|
||||
}
|
||||
// 无分割线
|
||||
|
||||
#pragma mark - Event
|
||||
|
||||
|
||||
Reference in New Issue
Block a user