zoukankan      html  css  js  c++  java
  • iOS自定义文字高度添加行间距

    在创建cell时- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath





    NSString * sttr = [NSString stringWithFormat:@"%@%@",arrayload[indexPath.row],arraymodeltext[indexPath.row]]; NSMutableAttributedString * strAttebute = [[NSMutableAttributedString alloc] initWithString:sttr ]; //设置行间距 NSMutableParagraphStyle * paragraphStlyle = [[NSMutableParagraphStyle alloc] init]; [paragraphStlyle setLineSpacing:IPHONEHIGHT(10)]; [strAttebute addAttribute:NSParagraphStyleAttributeName value:paragraphStlyle range:NSMakeRange(0, sttr.length)]; [strAttebute addAttribute:NSForegroundColorAttributeName value:qianse range:NSMakeRange(0, [arrayload[indexPath.row] length])]; full.labelText.attributedText = strAttebute; CGSize contentSize = [sttr boundingRectWithSize:CGSizeMake(ScreenWidth-IPHONEHIGHT(56),MAXFLOAT ) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:IPHONEWIDTH(30)]} context:NULL].size; full.labelText.size =CGSizeMake(contentSize.width, contentSize.height); height0 = contentSize.height; return full;
  • 相关阅读:
    2. Django每日一码 之as_view() 源码
    gdb
    Mex文件在VS2010中调试方法
    intel ipp6.0安装过程
    C++开源库大全
    Win7下搭建Go语言开发环境
    for_each使用方法详解
    使用VS2012编译和使用C++ STL(STLport)
    django css
    google mock C++单元测试框架
  • 原文地址:https://www.cnblogs.com/xujiahui/p/6689347.html
Copyright © 2011-2022 走看看