iOS 6中如何下划线?

我试图在标签中强调一些文字.但是,我不知道如何获取标签中整个文本的范围.这是我到目前为止
NSMutableAttributedString *mat = [self.tableLabel.attributedText mutablecopy];
[mat addAttributes:@{NSUnderlinestyleAttributeName: @(NSUnderlinestyleSingle)} range://??];
self.tableLabel.attributedText = mat;

我应该为范围做些什么?

解决方法

对于您可能想要使用的范围:
NSMakeRange (0,mat.length);

喜欢这个:

NSMutableAttributedString *mat = [self.tableLabel.attributedText mutablecopy];
[mat addAttributes:@{NSUnderlinestyleAttributeName: @(NSUnderlinestyleSingle)} range:NSMakeRange (0,mat.length)];
self.tableLabel.attributedText = mat;

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...