当前位置: 代码迷 >> 综合 >> iOS8.0+ NSMutableAttributedString在末尾换行处插入图片不显示
  详细解决方案

iOS8.0+ NSMutableAttributedString在末尾换行处插入图片不显示

热度:88   发布时间:2023-12-07 00:01:46.0

解决方案:

    NSMutableAttributedString *mutableAttributedString = [[NSMutableAttributedStringalloc] init];

    NSMutableAttributedString *atr = [[NSMutableAttributedStringalloc]initWithString:@"\uFFFC "];

    NSTextAttachment *attach = [[NSTextAttachmentalloc]init];

    attach.image = image;

    attach.bounds =CGRectMake(0, -2,titleFontSize, titleFontSize);

    [atr setAttributes:@{ NSAttachmentAttributeName:attach}range:NSMakeRange(0, atr.length)];

    [mutableAttributedString appendAttributedString:atr];


\uFFC为对象占位符