INDLinkLabel
INDLinkLabel copied to clipboard
text alignment
Tried using .textalignment but didn't work and I couldn't see any attributes with NSTextContainer that dealt with text alignment.
Is this possible?
Looks like a bug, good catch! In the mean time, you can create an NSMutableParagraphStyle
and set the alignment
property, and then set that object in the attributes dictionary of your NSAttributedString
using the NSParagraphStyleAttributeName
key.
@indragiek Cool, thanks for the suggestion!
var txtstyle = NSMutableParagraphStyle()
txtstyle.alignment = NSTextAlignment.Center
let RTFPath = NSBundle.mainBundle().pathForResource("text", ofType: "rtf")!
let RTFData = NSData(contentsOfFile: RTFPath)!
let options = [NSDocumentTypeDocumentAttribute: NSRTFTextDocumentType, NSParagraphStyleAttributeName : txtstyle]
policyLabel.numberOfLines = 0
policyLabel.attributedText = NSAttributedString(data: RTFData, options: options, documentAttributes: nil, error: nil)
policyLabel.delegate = self
Just tried this and it didn't work!
NSParagraphStyleAttributeName
is a key that can't be passed in the options
parameter as you have there. In this case, you will need to create an NSMutableAttributedString
and apply the attribute like this:
let attrString = NSMutableAttributedString(data: RTFData, options: options, documentAttributes: nil, error: nil)
attrString.addAttribute(NSParagraphStyleAttributeName, value: style, range: NSMakeRange(0, attrString.length))
policyLabel.attributedText = attrString;
@indragiek Thanks! Got it to work
This ticket shouldn't be closed. Is still an issue :)
@raulriera Good point!