I\'m creating an iOS app, and I would like to display an attributed string with specific tab stops specified in a UITextView. I would also like to draw them directly into U
This is the Swift version that worked for me:
let tablInterval: CGFloat = 85.0
let paragraphStyle = NSMutableParagraphStyle()
let terms = NSTextTab.columnTerminatorsForLocale(NSLocale.currentLocale())
let tabStop0 = NSTextTab(textAlignment: .Right, location: 0, options: [NSTabColumnTerminatorsAttributeName:terms])
let tabStop1 = NSTextTab(textAlignment: .Right, location: tablInterval, options: [NSTabColumnTerminatorsAttributeName:terms])
let tabStop2 = NSTextTab(textAlignment: .Right, location: tablInterval*2, options: [NSTabColumnTerminatorsAttributeName:terms])
let tabStop3 = NSTextTab(textAlignment: .Right, location: tablInterval*3, options: [NSTabColumnTerminatorsAttributeName:terms])
paragraphStyle.addTabStop(tabStop0)
paragraphStyle.addTabStop(tabStop1)
paragraphStyle.addTabStop(tabStop2)
paragraphStyle.addTabStop(tabStop3)
let attributedString = NSMutableAttributedString(string:text)
attributedString.addAttribute(NSParagraphStyleAttributeName, value:paragraphStyle, range:rangeAll)