我想在我的标签文本之间包含 png 图像。如何在 objective-c 中进行处理。
最佳答案
如果有人觉得有用,这是答案----->
NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
attachment.image = [UIImage imageNamed:@"Attach-52.png"];
NSAttributedString *attachmentString = [NSAttributedString attributedStringWithAttachment:attachment];
NSMutableAttributedString *myString= [[NSMutableAttributedString alloc] initWithString:@"My label text"];
[myString appendAttributedString:attachmentString];
myLabel.attributedText = myString;
同样,您可以通过 NSAttributedString 添加 png 图像。
关于ios - 如何在标签文本之间包含 png 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36996682/