Skip to content

Commit

Permalink
add-post
Browse files Browse the repository at this point in the history
  • Loading branch information
yznote committed Sep 11, 2024
1 parent 1193bd3 commit 02e816c
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions _posts/2024-09-11-YYLabel富文本.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
layout: post
title: YYLabel富文本
subtitle: 富文本
date: 2024-09-11 17:36:00 GMT+0800
author: 920
header-img:
catalog: true
stickie: false
tags:
- 富文本
---


#### 富文本显示

- yylabel中不能使用NSTextAttachment来处理富文本

**正确方案**

```
UIImageView *imageV = [[UIImageView alloc] init];
imageV.frame = CGRectMake(0, -2, 15, 15);
imageV.image = emojiImage;
NSAttributedString *imageString = [NSAttributedString yy_attachmentStringWithContent:imageV contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(15, 15) alignToFont:_contentL.font alignment:YYTextVerticalAlignmentCenter];
_contentL.attributedText = imageString;
```

**或者**

```
UIImage *image = [UIImage imageNamed:@"壁纸-详情-编辑"];
NSMutableAttributedString *attachment = [NSMutableAttributedString yy_attachmentStringWithContent:image contentMode:UIViewContentModeCenter attachmentSize:CGSizeMake(15, 15) alignToFont:SYS_Font(15) alignment:(YYTextVerticalAlignment)YYTextVerticalAlignmentCenter];
```

[连接](https://yznote.github.io/2019/10/25/%E5%AF%8C%E6%96%87%E6%9C%AC/)

0 comments on commit 02e816c

Please sign in to comment.