Changing font formattings of selected word/line in a UITextView

一个人想着一个人 提交于 2019-12-12 23:46:21

问题


Has anyone tried to change the font formatting(bold/italic/color) of a selected word or sentence in a UITextView, like a text editor application? I have been trying to do this but it seems formatting is applied only to the whole text, not on individual words or sentences.


回答1:


UITextView cannot style text fragments. Styles, colors and fonts are applied to the entire text. You may wish to use a UIWebView or Core Text to render your text instead.




回答2:


you can change any specific word font, style and size also,

Make UITextView text to "Attributed", by default it was "Plain" and then you can perform edition on selected text.



来源:https://stackoverflow.com/questions/4688268/changing-font-formattings-of-selected-word-line-in-a-uitextview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!