iOS -- YYText富文本


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;  //設置富文本

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM