I have an NSAttributedString
, I need to insert some text in the middle of the text in my attributedString, how can i do that?
NSAttributedString *someAttrString = ...; // the original string you want to modify
NSAttributedString *someOtherAttrString = ...; // the text you want to insert
NSUInteger whereItGoes = ...; // where you want to insert the string
NSMutableAttributedString *mutableString = [someAttrString mutableCopy];
if (mutableString) {
[mutableString insertAttributedString: someOtherAttrString atIndex: whereItGoes];
// mutableString now contains the modified data; it's up to you
// how it gets used in your app.
[mutableString release];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With