ios中怎么手动调label的行距

来源:互联网 发布:网络游戏客户端编程 编辑:程序博客网 时间:2024/04/28 01:41
//手动调行距
+(NSAttributedString *) customSpacing:(CGFloat)space andStr:(NSString *)text{

    
    NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
   
    [paragraphStyle setLineSpacing:space];
    UIColor *color = RGB(51, 51, 51);
    
    UIFont *font = [UIFont fontWithName:@"PingFangSC-Regular" size:14];
    
    NSAttributedString *string = [[NSAttributedString alloc] initWithString:text attributes:@{NSForegroundColorAttributeName : color, NSParagraphStyleAttributeName: paragraphStyle,NSFontAttributeName: font}];

    return string;
}
0 0