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

Any way to change lineHeight? #62

Open
kboirel opened this issue Jan 27, 2020 · 3 comments
Open

Any way to change lineHeight? #62

kboirel opened this issue Jan 27, 2020 · 3 comments

Comments

@kboirel
Copy link

kboirel commented Jan 27, 2020

Hi,

I would like to use that lib to format my label.
The idea is that I have a structure like this:
title1
Description1

title2
Description2

etc...

I would like to have some space between the title and the description. one "\n" is not enough and "\n\n" is too much.
Do you have any idea about how I could do that?

@kacper1703
Copy link

extension NSMutableAttributedString {
    func setLineSpacing(_ spacing: CGFloat) {
        let paragraphStyle = NSMutableParagraphStyle()
        paragraphStyle.lineSpacing = spacing
        let attributes: [NSAttributedString.Key: Any] = [
            NSAttributedString.Key.paragraphStyle: paragraphStyle
        ]

        let range = (string as NSString).range(of: string)
        addAttributes(attributes, range: range)
    }
}

@BrandonCao
Copy link

Im trying to do this for a list right now and it's not working

@jeanbaptistebeau
Copy link

+1

How to change line spacing for the whole text, or for specific elements?

@kacper1703 how would you integrate this code with the MarkdownKit library?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants