Skip to content

Instantly share code, notes, and snippets.

@GnuRant
Created September 10, 2015 08:30
Show Gist options
  • Save GnuRant/84da17a44e46042206df to your computer and use it in GitHub Desktop.
Save GnuRant/84da17a44e46042206df to your computer and use it in GitHub Desktop.
//
// .-
// `+d/
// -hmm/
// ommmm/
// `mmmmm/
// `mmmmm/ .:+ssyso+-`
// `mmmmmsydmmmmmmmmmho.
// `mmmmmmh+:---/+ssssyd:
// `mmmmmh. / .md-
// `mmmmmo..-` .ommo
// `mmmmm+..` ./oydmmm/
// `mmmmm/ /dmmmmmmh`
// `mmmmm/ `smmmmmmms`
// `mmmmm/ `+dmmmmmy+.
// :::::. `-::-.`
//
// Created by Luca D'incà on 10/09/15.
// Copyright (c) 2015 B3LAB. All rights reserved.
//
// UILabel+Lineheight.swift
// Quartzforms
//
import UIKit
extension UILabel {
func setLineHeight(lineHeight: CGFloat) {
let text = self.text
if let text = text {
let attributeString = NSMutableAttributedString(string: text)
let style = NSMutableParagraphStyle()
style.lineSpacing = lineHeight
attributeString.addAttribute(NSParagraphStyleAttributeName, value: style, range: NSMakeRange(0, count(text)))
self.attributedText = attributeString
}
}
}
@henningsoft
Copy link

Updated line 36 with Swift 5

attributeString.addAttribute(NSAttributedString.Key.paragraphStyle, value: style, range: NSMakeRange(0, attributeString.length))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment