你怎么能达到这个效果:
也许是某种NSAtributedString?
我曾想过只添加空格的hacky方法,但它需要根据图像的宽度动态地进行.
有任何想法吗?
请注意,您可以使用UITextView轻松完成此操作:
https://stackoverflow.com/a/20033752/294884
这个问题是关于UILabel的.
解决方法
使用文本在标签中添加图片,如下所示:
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"Here is some text that is wrapping around like an image"]; NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init]; textAttachment.image = [UIImage imageNamed:@"first.jpg"]; NSAttributedString *attrStringWithImage = [NSAttributedString attributedStringWithAttachment:textAttachment]; [attributedString insertAttributedString:attrStringWithImage atIndex:0]; [_lbn setAttributedText:attributedString];
你的输出: