I have one string as instance var and I want to draw it in two different fonts in parts.
to be specific it reads : xyz(abc) .
ie: I want to draw ‘xyz()’ part with normal font and ‘abc‘ in italics.
This string is a property and the view is generic . Only in a specific case It should display string like this.
I tried NSAttributedString and its Mutable version but it seems its not fully supported on iOS.
Couldn’t get the Keys for attributes, How should I go about this ?
Is there anywayto use NSAttributedString here ?
I would subclass UIView to draw using core text and pass it a customized NSAttributed string,
Off the top of my head something like this:
so outside of this you would call the setter for the attribtued string and it should redraw.
you would also apply custom traits to ranges of the NSAttributd string BEFORE you send it to the view. You could use regexp or just general string searching to find it.
i.e
code wise it might be slightly different – am on my non-work machine sorry so can’t validate it 100%,
also from memory this is how you can apply an italic trait to the current font of the attributed string
Hope it helps.