zoukankan      html  css  js  c++  java
  • 更UIlabel改行间距

    / 更改行间距

                NSString *dLabelString = cell.Content.text;

                

                NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:dLabelString];

                NSMutableParagraphStyle   *paragraphStyle   = [[NSMutableParagraphStyle alloc] init];

                

                //行间距

                [paragraphStyle setLineSpacing:5.0];

                //段落间距

                [paragraphStyle setParagraphSpacing:10.0];

                //第一行头缩进

                [paragraphStyle setFirstLineHeadIndent:15.0];

                //头部缩进

                //[paragraphStyle setHeadIndent:15.0];

                //尾部缩进

                //[paragraphStyle setTailIndent:250.0];

                //最小行高

                //[paragraphStyle setMinimumLineHeight:20.0];

                //最大行高

                //[paragraphStyle setMaximumLineHeight:20.0];

                

                [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [dLabelString length])];

                [cell.Content setAttributedText:attributedString];

                

                [cell.Content setLineBreakMode:NSLineBreakByTruncatingTail];

                

                CGRect dlRect = cell.Content.frame;

                [cell.Content sizeToFit];

                CGRect dlRectNew = cell.Content.frame;

                if(dlRectNew.size.height>dlRect.size.height){  

                    dlRectNew.size.height = dlRect.size.height;  

                    [cell.Content setFrame:dlRectNew];

                }

  • 相关阅读:
    (原创)C++ IOC框架
    【教训】为什么不作备份?!
    【教训】php pcntl_fork无法在web服务器环境下使用
    PHP多进程处理并行处理任务实例
    mysql数据库授权
    PHPUnit学习03使用Mock对象解决测试依赖
    [Inside] How to solve one problem?
    [Inside] What’s the assumptions you are making
    算法面试题解答(六)
    [Inside] System Thinking
  • 原文地址:https://www.cnblogs.com/-ios/p/5834252.html
Copyright © 2011-2022 走看看