Swift Attributed Left Intended Numbered List
Asked Answered
A

1

6

I am using below code to create a list of rules in an alert style UIAlertController

let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = NSTextAlignment.Left
let messageText = NSMutableAttributedString(
    string: "1. Do not bully or target other users.\n2. Do not post others' private information.\n3. Do not post useless or offensive content.\n4. Do not post others' copyrighted content.\n5. Downvote and Flag posts which violate these rules.\n6. If you violate these rules, your account may be suspended and/or your content removed.",
    attributes: [
        NSParagraphStyleAttributeName: paragraphStyle,
        NSFontAttributeName : UIFont(name: "Lato-Regular", size: 13.0)!,
        NSForegroundColorAttributeName : colorAccentWords
    ]
)

It gives me alert view as shown below: enter image description here

What I want is to make the numbered list left intended so that overflow text from each line will be left aligned. How can I achieve that?

Ailey answered 27/6, 2015 at 15:52 Comment(0)
E
8

Set the headIndent property of paragraphStyle to an appropriate value, for example

paragraphStyle.headIndent = 13.0
Earshot answered 27/6, 2015 at 16:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.