【Swift】首行缩进两个字符

2018-09-04  本文已影响55人  MMD_
        let paraStyle01 = NSMutableParagraphStyle()
        paraStyle01.alignment = .left
        //对齐
        paraStyle01.headIndent = 0.0
        //行首缩进
        //参数:(字体大小17号字乘以2,34f即首行空出两个字符)
        let emptylen: CGFloat = contentLabel.font.pointSize * 2
        
        paraStyle01.firstLineHeadIndent = emptylen
        //首行缩进
        paraStyle01.tailIndent = 0.0
        //行尾缩进
        paraStyle01.lineSpacing = 2.0
        //行间距
        let attrText = NSAttributedString(string: model.msgContent ?? "", attributes: [.paragraphStyle: paraStyle01])
        contentLabel.attributedText = attrText

上一篇下一篇

猜你喜欢

热点阅读