以UILabel 顶部添加横线为例,
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont systemFontOfSize:12];
label.textColor = [UIColor colorWithHexString:@"767676"];
label.text = validExchangeText;
label.textAlignment = NSTextAlignmentCenter;
//self.stackView 是父控件
[self.stackView addArrangedSubview:label];
UIView *line = [[UIView alloc] init];
line.backgroundColor = [UIColor colorWithHexString:@"B3B3B3" withAlpha:0.3f];
[label addSubview:line];
[line mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(@16);
make.centerX.equalTo(@0);
make.top.equalTo(@0);
make.height.equalTo(@0.5);
}];
[label mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.equalTo(@56);
}];