美文网首页
label行间距

label行间距

作者: 严念仁 | 来源:发表于2017-05-03 17:02 被阅读9次
    UILabel *label = [[UILabel alloc] init];
    label.font = [UIFont sportsFontNormal];
    label.textColor = [UIColor sportsGrayColor];
    label.textAlignment = NSTextAlignmentLeft;
    label.numberOfLines = 0;
    [view addSubview:label];
    NSString *labelText = @"我是测试员我是测试员;我是测试员我是测试员我是测试员我是测试员我是测试员我是测试员我是测试员我是测试员我是测试员我是测试员";
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:labelText];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    [paragraphStyle setLineSpacing:10.0f];//调整行间距
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [labelText length])];
    label.attributedText = attributedString;
    [label sizeToFit];
    

    相关文章

      网友评论

          本文标题:label行间距

          本文链接:https://www.haomeiwen.com/subject/msqltxtx.html