2017-01-11 34 views

回答

-1

你可能會尋找一個「所見即所得」的文本視圖。

您可以嘗試在線搜索WYSIWYG html ios並查看最適合您的庫。例如,ZSSRichTextEditor是適用於iOS的富文本編輯器。您只需轉換UITextView並獲取更改輸出html的額外按鈕即可。 (粗體,下劃線,顏色等)

+0

NSString * str = textView.attributedText; –

0

TextView只能顯示簡單文本。 你可以在UIWebView中顯示html。

+1

TextView可以顯示任何文本。包括一個HTML字符串。 – NSNoob

0
NSAttributedString *articleText = _txtView.attributedText; 

NSDictionary *documentAttributes = @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType}; 

NSData *htmlData = [articleText dataFromRange:NSMakeRange(0, articleText.length) documentAttributes:documentAttributes error:NULL]; 
NSString *str = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding]; 
NSLog(@"%@", str); 
相關問題