ios - Swift: strikethroughStyle For Label (Middle Delete Line For Label)

标签 ios swift xcode uilabel strikethrough

如何为标签添加删除线样式。 UILabel 中数字的中间删除行。查看附件图片以供引用。

enter image description here

最佳答案

使用属性字符串

截图

enter image description here

代码

NSDictionary * attribtues = @{NSStrikethroughStyleAttributeName:@(NSUnderlineStyleSingle),
                              NSStrikethroughColorAttributeName:[UIColor redColor]};
NSAttributedString * attr = [[NSAttributedString alloc] initWithString:@"label" attributes:attribtues];
self.label.attributedText = attr;

关于ios - Swift: strikethroughStyle For Label (Middle Delete Line For Label),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33818529/

相关文章:

ios - EKEvent 获取当前事件 iOS7

objective-c - 如何为UIImage的drawAsPatternInRect指定图像偏移

ios - 在 UITableViewCell 中扩展 UITextView 高度(查看更多效果)

swift - BindableObjects 数组 SwiftUI

iphone - 在 Bump Api 发送图像方面需要一些帮助

ios - Swift - 访问 UIVIewcontroller 可变数组到 UITableViewCell 类

ios - iOS 按文本宽度对 UITableView 进行排序

ios - 解析目标 - C 到 Swift iOS

ios - EZAudio 无法工作 : Thread1 EXC_BAD_ACCESS while creating EZRecorder instance

swift - 使用重载函数作为一等公民