有没有办法通过UILabel添加一条简单的线.我有一个40px高的UILabel,只想在中间水平画一条黑线(20px).有没有办法在不创建图像并将其设置为背景的情况下执行此操作?
如果你的标签包含文字,那么你可以在标签中使用这样的标记.
Objective-C的
NSString *newStringStrike = @"your text";
NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:newStringStrike];
[attributeString addAttribute:NSStrikethroughStyleAttributeName
value:@1
range:NSMakeRange(0, [attributeString length])];
labelName.attributedText = attributeString;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3236 次 |
| 最近记录: |