Swift/OC

来源:互联网 发布:电磁场有限元分析软件 编辑:程序博客网 时间:2024/06/10 03:38

这个没什么好讲的,直接上代码,知道swift中设置行间距的样式就行。附加上OC版设置:

Swift4.0 let paragraphStye = NSMutableParagraphStyle() //调整行间距 paragraphStye.lineSpacing = 5.0 paragraphStye.lineBreakMode = NSLineBreakMode.byWordWrapping let attributedString = NSMutableAttributedString.init(string: self.contentLab.text!, attributes: [NSAttributedStringKey.paragraphStyle:paragraphStye]) self.contentLab.attributedText = attributedString
OC版:NSMutableAttributedString *attriText = [[NSMutableAttributedString alloc] initWithString:content];NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];[paragraphStyle setLineSpacing:5];[paragraphStyle setLineBreakMode:NSLineBreakByWordWrapping];[attriText addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontSize],NSForegroundColorAttributeName:UIColorFromRGB(0x333333,1),NSParagraphStyleAttributeName:paragraphStyle} range:NSMakeRange(0, content.length)];

有问题请发送邮件到:584379066@qq.com , 请备注

原创粉丝点击