iOS UILabel行间距字间距
2019-11-30 本文已影响0人
倪大头
NSMutableDictionary *attr = [NSMutableDictionary dictionary];
//字间距(NSKernAttributeName)
attr[NSKernAttributeName] = @5;
//行间距(NSParagraphStyleAttributeName)
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:5];
attr[NSParagraphStyleAttributeName] = paragraphStyle;
myLabel.attributedText = [[NSAttributedString alloc]initWithString:myLabel.text attributes:attr];
myLabel.numberOfLines = 0;
myLabel.lineBreakMode = NSLineBreakByWordWrapping;