zoukankan      html  css  js  c++  java
  • 解决 label 多行间距

    使用。 一个是间距,一个是行高,但是鉴于多行,都写的话,就相当于双倍行高了。我就用行高代替间距。

     1 self.textLabel.attributedText = [self getAttributedStringWithString:self.textString lineSpace:0 baselineOffset:10]; 

    方法如下

     1 -(NSAttributedString *)getAttributedStringWithString:(NSString *)string lineSpace:(CGFloat)lineSpace baselineOffset:(CGFloat)baselineOffset {
     2     NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string];
     3     NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
     4     paragraphStyle.lineSpacing = lineSpace; // 调整行间距
     5     NSRange range = NSMakeRange(0, [string length]);
     6     [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:range];
     7     // 设置文本偏移量
     8     [attributedString addAttribute:NSBaselineOffsetAttributeName value:@(baselineOffset) range:range];
     9     return attributedString;
    10 }
    让明天,不后悔今天的所作所为
  • 相关阅读:
    某个sql帖子的答题
    JQuery hide
    JQuery tr 循环,删除td
    JQuery Disabled
    QueryString大小设置
    Silverlight HelloWorld
    USB HID通讯流程
    动态调用c++dll(转)
    VB应用程序调用c++编写的动态库(dll)(转)
    读取图像
  • 原文地址:https://www.cnblogs.com/-yun/p/5420305.html
Copyright © 2011-2022 走看看