簡體   English   中英

在uitextview內部加下划線文本

[英]Underline text inside uitextview

如何以編程方式在uitextview中加下划線?

您可以為此使用NSAttributedString。 以下是相同的鏈接-https://github.com/AliSoftware/Ali-Cocoa-Classes

您可以引用該線程來檢查如何使用NSAttributedString。 您如何使用NSAttributedString?

我使用UIWebView代替UITextView來解決此問題。

NSString *contentHtml = [NSString stringWithFormat:@"<html><head></head><body><font color=\"white\" size=\"4\"><table width=\"260px\"><tr><td align=\"left\" width=\"160px\"><u>Left:</u></td><td align=\"right\" width=\"100px\">315</td></tr></table></font></body></html>"];
[listWebView loadHTMLString:contentHtml baseURL:nil];
NSMutableAttributedString *attributedString = [self.textView.attributedText mutableCopy];   
int valueToSet = kCTUnderlineStyleSingle;
[attributedString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:valueToSet] range:CGMakeRange(0, self.textView.text.length)];

self.textView.attributedText = attributedString;
[attributedString release];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM