Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UILabel 행간(Line Spacing 조절하기) #25

Open
chaneeii opened this issue Aug 17, 2022 · 0 comments
Open

UILabel 행간(Line Spacing 조절하기) #25

chaneeii opened this issue Aug 17, 2022 · 0 comments
Labels
TIL Today I Learned UIKit UIKit

Comments

@chaneeii
Copy link
Owner

chaneeii commented Aug 17, 2022

extension UILabel {
    func setLineSpacing(spacing: CGFloat) {
        guard let text = text else { return }

        let attributeString = NSMutableAttributedString(string: text)
        let style = NSMutableParagraphStyle()
        style.lineSpacing = spacing
        attributeString.addAttribute(.paragraphStyle,
                                     value: style,
                                     range: NSRange(location: 0, length: attributeString.length))
        attributedText = attributeString
    }
}

// ✅ 사용방법
titlelabel.setLineSpacing(spacing: 13.0)

https://ios-development.tistory.com/739

@chaneeii chaneeii added UIKit UIKit TIL Today I Learned labels Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TIL Today I Learned UIKit UIKit
Projects
None yet
Development

No branches or pull requests

1 participant