我有一个 NSAttributedString
,我需要在我的 attributedString 中的文本中间插入一些文本,我该怎么做?
最佳答案
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];
}
关于iphone - Objective-C - 在 NSAttributedString 中插入字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6644731/