iOS 关于UIlabe 行间距设置

  ///设置每行间距

    NSMutableDictionary *textDict = [NSMutableDictionary dictionary];

    textDict[NSKernAttributeName] = @(1);

    label.attributedText = [[NSAttributedString alloc] initWithString:label.text attributes:textDict];

    NSMutableAttributedString *text1 = [[NSMutableAttributedString alloc] initWithString:label.text];

    //设置缩进、行距

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

    style.alignment = NSTextAlignmentLeft;

    style.lineSpacing = 5;

    [text1 addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, text1.length)];

    label.attributedText = text1;

 

        lable.frame = CGRectMake(0, 0, contexWidth,titleSize.height + (titleSize.height/singetHeight ) * 5);

 

posted @ 2020-09-24 23:39  一起开拓吧  阅读(125)  评论(0编辑  收藏  举报