我有一个NSAttributedString
,我需要在我的属性字符串的中间插入一些文本,我该怎么做?
问问题
4991 次
1 回答
15
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];
}
于 2011-07-11T01:07:02.393 回答