本文介绍了如何在iOS 6中为文本加下划线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在标签中加下一些文字。但是,我不知道如何获得标签中整个文本的范围。这就是我到目前为止:
I am trying to underline some text in a label. However, I do't know how to get the range of the entire text in the label. This is what I have so far:
NSMutableAttributedString *mat = [self.tableLabel.attributedText mutableCopy]; [mat addAttributes:@{NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle)} range://??]; self.tableLabel.attributedText = mat;我应该为该范围添加什么?
What should I put for the range?
推荐答案对于您可能想要使用的范围:
For the range you may want to use:
NSMakeRange (0, mat.length);喜欢这样:
NSMutableAttributedString *mat = [self.tableLabel.attributedText mutableCopy]; [mat addAttributes:@{NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle)} range:NSMakeRange (0, mat.length)]; self.tableLabel.attributedText = mat;更多推荐
如何在iOS 6中为文本加下划线?
发布评论