Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift Attributed Left Intended Numbered List

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?

like image 915
Kashif Avatar asked Jun 27 '15 15:06

Kashif


1 Answers

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

paragraphStyle.headIndent = 13.0
like image 50
vadian Avatar answered Oct 19 '22 19:10

vadian