gpt4 book ai didi

iphone - Objective-C - 在 NSAttributedString 中插入字符串?

转载 作者:太空狗 更新时间:2023-10-30 03:31:26 24 4
gpt4 key购买 nike

我有一个 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com