This commit is contained in:
2025-11-11 15:13:43 +08:00
parent 17b8bf2bfd
commit e34288ae56
6 changed files with 145 additions and 78 deletions

View File

@@ -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