Answers for "negative line spacing swift"

1

swift negative line spacing

var attrString = NSMutableAttributedString(string: labelText)
var style = NSMutableParagraphStyle()
let minMaxLineHeight = font.pointSize - font.ascender + font.capHeight
let offset = NSNumber(value: Float(font.capHeight - font.ascender))
let range = NSRange(location: 0, length: labelText.length)
style.minimumLineHeight = minMaxLineHeight
style.maximumLineHeight = minMaxLineHeight
if isCentered {
    style.alignment = .center
}
attrString.addAttribute(.paragraphStyle, value: style, range: range)
attrString.addAttribute(.baselineOffset, value: offset, range: range)

labelText.attributedText = attrString
Posted by: Guest on April-17-2020

Code answers related to "Swift"

Browse Popular Code Answers by Language