美文网首页
YYLabel 常用方法 2022-02-25

YYLabel 常用方法 2022-02-25

作者: iOS打怪升级 | 来源:发表于2022-02-25 13:49 被阅读0次
1. 设置空心区域<显示特殊标签>

原理就是设置不显示文字的区域,用于显示图片的内容;
注意设置最大宽度,否则不会换行preferredMaxLayoutWidth

+ (YYTextContainer *)getLiveThemeTextContainer:(CGFloat)indent
{
    //liveThemeLabel的宽度
    CGFloat width = kScreen_Width - 175;
    UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, width, 60)];
    UIBezierPath *headIndentPath = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, indent, 16)];
    YYTextContainer *container = [YYTextContainer containerWithPath:path];
    container.exclusionPaths = @[headIndentPath];
    
    return container;
}
YYLabel *classNameLabel = nil;
   _classNameLabel = [[YYLabel alloc] init];
    _classNameLabel.text = @"            --";
    _classNameLabel.font = HQ_Font_Medium(14);
    _classNameLabel.numberOfLines = 2;
//注意设置最大宽度,否则不会换行的
    _classNameLabel.preferredMaxLayoutWidth = kScreen_Width - 175;
    [_containView addSubview:_classNameLabel];

 NSAttributedString *attri = xxxxxx;
 YYTextContainer *container = [[self class] getLiveThemeTextContainer:indent];
 YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:attri];
classNameLabel.textLayout = layout;

相关文章

  • YYLabel 常用方法 2022-02-25

    1. 设置空心区域<显示特殊标签> 原理就是设置不显示文字的区域,用于显示图片的内容;注意设置最大宽度,否则不会换...

  • YYLabel富文本显示

    YYLabel实现方式 //1.简单显示label YYLabel *label = [YYLabel new];...

  • iOS YYText之YYLabel源码阅读(一)

    我用以下几个问题去阅读YYLabel的源码:问题1:YYLabel如何刷新?问题2:YYLabel动态高度计算?问...

  • YYLabel简单使用

    最近尝试研究了一下YYLabel,学习了一下YYLabel文本响应点击及YYLabel换行功能,下面介绍一下我的收...

  • YYLabel 给超出文字变成省略号

    最近研究了一下yylabel,遇到一个问题 yylabel.lineBreakMode = NSLineBreak...

  • YYLabel富文本

    YYLabel与UILabel对表情的支持YYLabel只支持YYTextAttachment,不支持系统默认的N...

  • YYKit框架学习之YYLabel

    一、YYLabel 强大的富文本显示功能,可根据文字的range随意添加点击事件 1 自动换行 YYLabel *...

  • iOS-文本内容展开/收起实现方案

    方案1:YYLabel 问题:YYLabel继承于UIView不支持项目本身的自定义表情,UILabel能正常显示...

  • YYLabel

    YYLabel 继承View,功能更加强大,支持所有UILabel的特性 1.可以实现垂直文字文字布局 @prop...

  • YYKit--YYLabel源码分析

    一、YYLabel实现的总体思路 其实YYLabel主要就是为了实现异步绘图,提高性能,为此做了好多东西。 1、使...

网友评论

      本文标题:YYLabel 常用方法 2022-02-25

      本文链接:https://www.haomeiwen.com/subject/dbmxrrtx.html