Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问怎么才能支持NSAttachmentAttributeName,NSTextAttachment #27

Open
MiaYY opened this issue Feb 11, 2022 · 1 comment
Open

Comments

@MiaYY
Copy link

MiaYY commented Feb 11, 2022

因为需要展示自己设计的系统表情类图片,需要将图片放在imageView上转换成Attachment展示

@lele8446
Copy link
Owner

CJLabel不支持NSTextAttachment的插入,但它提供比Attachment更灵活的展示方式,使用以下方法拼装数据源即可

/**
 在指定位置插入任意UIView
 
 注意!!!
 1、插入任意View, 如果设置 NSParagraphStyleAttributeName 属性,
    请保证 paragraph.lineBreakMode = NSLineBreakByCharWrapping,不然当Label的宽度不够显示内容或view时,不会自动换行, 部分view将会看不见
    默认 paragraph.lineBreakMode = NSLineBreakByCharWrapping
 2、插入任意View,如果 configure.isLink = YES,那么将优先响应CJLabel的点击响应
 
 @param attrStr       源字符串
 @param view          需要插入的view(包括UIImage,NSString图片名称,UIView)
 @param size          view的显示区域大小
 @param loc           插入位置
 @param lineAlignment 插入view所在行,与文字在垂直方向的对齐方式(只针对当前行)
 @param configure     链点配置
 @return              NSAttributedString
 */
+ (NSMutableAttributedString *)insertViewAtAttrString:(NSAttributedString *)attrStr
                                                 view:(id)view
                                             viewSize:(CGSize)size
                                              atIndex:(NSUInteger)loc
                                        lineAlignment:(CJLabelVerticalAlignment)lineAlignment
                                            configure:(CJLabelConfigure *)configure;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants