首页 > 系统 > iOS > 正文

iOS - UILabel设置行间距及文字居中

2019-11-06 09:40:22
字体:
来源:转载
供稿:网友

效果

// 调整行间距NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:str];NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];// 设置文字居中paragraphStyle.alignment = NSTextAlignmentCenter;[paragraphStyle setLineSpacing:12];[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [str length])];txt.attributedText = attributedString;
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表