如何在iOS 6中为文本加下划线?

编程入门 行业动态 更新时间:2024-10-16 19:25:43
本文介绍了如何在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中为文本加下划线?

本文发布于:2023-07-18 12:47:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1144915.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:下划线   中为   文本   如何在   iOS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!