问题
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