Give Attributes to Specific TextView Index Range
My last post consisted of me asking how to give attributes to characters you are currently typing.
This thread's about how to give attributes to a specific range of text in a TextView object. I already understand how to give attributed text to the characters you are typing, but not to the ones already typed. This is my big issue.
If anyone could show me some examples, and give insights, it would be very much appreciated.
you will want to take a look at
addAttibutes_range_will let you add an attribute -- first argument is a dictionary of attributes, second is a NSRange object, which can be created by NSRange(start, length).
you can also use
addAttribute_value_range_where you use a single string attribute name and value rather than packed in a dictionary.
Also of interest may be the corresponding removeAttribute... and setAttribute... methods.
I am not sure, but you might need to preceed these with a
beginEditingand end with
endEditing, and might need to use
on_main_thread. Also, this needs to be a NSMutableAttributedAtring, which is writable.
Oh, you're a life saver. Thank you so much. I was looking all over the developer website and couldn't find that.