ios 修改uitextview 下划线距离文字
要修改UITextView的下划线距离文字,你可以使用NSAttributedString来自定义UITextView的文本属性。以下是一个示例代码,演示如何将下划线的距离设置为10个点:
// 创建一个NSMutableAttributedString对象,并设置文本内容和属性
NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:@"Hello, World!"];
// 设置下划线样式
[attributedText addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:NSMakeRange(0, attributedText.length)];
// 设置下划线距离文字的距离(以点为单位)
[attributedText addAttribute:NSUnderlineOffsetAttributeName value:@(10) range:NSMakeRange(0, attributedText.length)];
// 将NSAttributedString对象应用到UITextView
textView.attributedText = attributedText;
请注意,你需要将上述代码插入到你的视图控制器中,并将textView替换为你的UITextView对象
原文地址: http://www.cveoy.top/t/topic/h1nF 著作权归作者所有。请勿转载和采集!