lable计算行高_移动开发_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > 移动开发 > lable计算行高

lable计算行高

 2016/5/27 0:32:01  红街咖啡  程序员俱乐部  我要评论(0)
  • 摘要:_introduce.text=status.introduce;//设置行间距NSMutableAttributedString*attributedString=[[NSMutableAttributedStringalloc]initWithString:_introduce.text];;NSMutableParagraphStyle*paragraphStyle=[[NSMutableParagraphStylealloc]init]
  • 标签:
class="code_img_closed" src="/Upload/Images/2016052700/0015B68B3C38AA5B.gif" alt="" />logs_code_hide('66c83157-94b1-47c1-b4a2-b7b62b75b73d',event)" src="/Upload/Images/2016052700/2B1B950FA3DF188F.gif" alt="" />
 _introduce.text=status.introduce;
    
    //设置行间距
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:_introduce.text];;
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
    [paragraphStyle setLineSpacing:7];
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, _introduce.text.length)];
    
    _introduce.attributedText = attributedString;
    
    
    NSString *introduce=status.introduce;
    
    CGSize titleSize = [introduce boundingRectWithSize:CGSizeMake(KScreenWidth-80, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12],NSParagraphStyleAttributeName:paragraphStyle} context:nil].size;
    
    CGFloat height=titleSize.height;
    
View Code

 

  • 相关文章
发表评论
用户名: 匿名