Swift/OC - 设置行间距
2017-09-18 14:38
351 查看
这个没什么好讲的,直接上代码,知道swift中设置行间距的样式就行。附加上OC版设置:
有问题请发送邮件到:584379066@qq.com , 请备注
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 , 请备注
相关文章推荐
- iOS-OC-设置UITableViewCell之间的间距(推荐第四种)
- OC 如何设置UITableViewCell之间的间距
- Swift - 设置UILabel、UITextView的文字行间距
- 在oc项目中添加swift文件,并设置oc-swift混编
- 【swift,oc】ios开发中巧用自动布局设置自定义cell的高度
- Swift/OC设置tabbar
- 在oc项目中添加swift文件,并设置oc-swift混编
- Swift4 - 为UIButton多行文字设置间距
- Swift - 设置网格UICollectionView的单元格间距
- iOS-OC-设置UITableViewCell之间的间距
- 在oc项目中添加swift文件,并设置oc-swift混编
- iOS开发(OC)——文字的自适应高度和行间距的设置
- iOS-OC-设置UITableViewCell之间的间距(推荐第四种)
- iOS-设置控件不同方位的圆角(OC & Swift)
- 怎样把Button和Button之间的间距设置为0
- Swift基础之OC文件调用Swift代码(在上次的基础上写的)
- oc 和 swift 混编
- Swift - 设置应用程序图标的提醒个数(右上角小红圈)
- OC 与 Swift混编 Swift的闭包传值到OC中
- swift篇第五期:UITableView,OC与Swift互调