Skip to content

Use ListItemMarkup with NSTextList #5

Closed
@zhgchgli0718

Description

@zhgchgli0718

I found an attribute called NSTextList in NSMutableParagraphStyle, but after testing, I didn't see any benefit in using it because even when using NSTextList, we still need to manually append list items and padding to NSAttributedString.

sample code:

let attributedText = NSMutableAttributedString()
let paragraphStyle = NSMutableParagraphStyle()
let list = NSTextList(markerFormat: .circle, options: 0)
paragraphStyle.textLists = [list]
attributedText.append(NSAttributedString(string: "test"))
attributedText.append(NSAttributedString(string: "\(list.marker(forItemNumber: 1))testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest", attributes: [.paragraphStyle: paragraphStyle]))
attributedText.append(NSAttributedString(string: "test"))

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions