let titleParagraphStyle = NSMutableParagraphStyle()
titleParagraphStyle.alignment = .center
let titleFont = UIFont.preferredFont(forTextStyle: UIFontTextStyle.headline)
let title = NSMutableAttributedString(string: "You Are Registered",
attributes: [.font: titleFont,
.foregroundColor: UIColor.red,
.paragraphStyle: titleParagraphStyle])
let titleParagraphStyle = NSMutableParagraphStyle()
titleParagraphStyle.alignment = .center
let titleFont = UIFont.preferredFont(forTextStyle: UIFontTextStyle.headline)
let title = NSMutableAttributedString(string: "You Are Registered",
attributes: [NSFontAttributeName:titleFont,
NSForegroundColorAttributeName:UIColor.red,
NSParagraphStyleAttributeName: titleParagraphStyle])
(original answer below)
let titleParagraphStyle = NSMutableParagraphStyle()
titleParagraphStyle.alignment = .Center
let titleFont = UIFont.preferredFontForTextStyle(UIFontTextStyleHeadline)
let title = NSMutableAttributedString(string: "You Are Registered",
attributes:[NSFontAttributeName:titleFont,
NSForegroundColorAttributeName:UIColor.redColor(),
NSParagraphStyleAttributeName: titleParagraphStyle])