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# 全局热键
    Frida hook 初识
    xposed hook 复杂函数参数问题
    C# http post 中文乱码问题
    Fiddler 抓包https 问题
    C# HttpWebRequest 多线程超时问题
    Android Studio 无 Generate signed apk 菜单选项问题
    c#调用c++ dll const char* String类型转换问题。传值,与接收返回值问题
    C++中GB2312字符串和UTF-8之间的转换
    The underlying connection was closed: An unexpected error occurred on a send
  • 原文地址:https://www.cnblogs.com/-ios/p/5834252.html
Copyright © 2011-2022 走看看