首页 > 移动平台 > 详细

iOS -- YYText富文本

时间:2017-08-08 10:22:12      阅读:963      评论:0      收藏:0      [点我收藏+]
NSMutableAttributedString *text  = [[NSMutableAttributedString alloc] initWithString: [NSString stringWithFormat:@"%@", kRealName]];
    [text setYy_color:kDarkColor];
    NSMutableAttributedString *one  = [[NSMutableAttributedString alloc] initWithString: [NSString stringWithFormat:@"(%@)", kRole_name]];
    [one setYy_color:WhiteColor];
    [text appendAttributedString:one];
    titleLabel.attributedText = text;
    text.yy_lineSpacing = 5;
    text.yy_font = [UIFont systemFontOfSize:14];
   // text.yy_color = ThemeColor;
    __weak typeof(self) weakself = self;
   /*
    [text yy_setTextHighlightRange:NSMakeRange(10, 7) color:UIColorFromRGBValue(0x22b4e1) backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
        NSLog(@"xxx协议被点击了");
        
    }];
    */
    titleLabel.numberOfLines = 0;  //设置多行显示
    titleLabel.preferredMaxLayoutWidth = kScreenWidth - 30; //设置最大的宽度
    titleLabel.attributedText = text;  //设置富文本

 

iOS -- YYText富文本

原文:http://www.cnblogs.com/mafeng/p/7305271.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!