我使用NSAttributedString将图像插入到UITextView中,但问题是我想将顶部填充设置为几个点(2/3),以便图像y中心位于{{3文本。
这是我的代码:
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:currentMessage];
NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init];
textAttachment.image = [UIImage imageWithCGImage:[[imagesArray objectAtIndex:count] CGImage] scale:4.0 orientation:UIImageOrientationUp];
NSAttributedString *attrStringWithImage = [NSAttributedString attributedStringWithAttachment:textAttachment];
int newPos = [[imagesPosArray objectAtIndex:count] intValue];
[attributedString replaceCharactersInRange:NSMakeRange(newPos, 1) withAttributedString:attrStringWithImage];
messageTextView.attributedText = attributedString;