Text Kit and rich, attributed text

iOS doc: About text handling in iOS

Objc.IO

Setting margin and tabs

Start with the default style and alter it a mutable copy of it. Replace the default’s list of tabs stops, don’t add.

private func getRuler() -> NSParagraphStyle
{
    let indent = CGFloat(72.0 * 0.5)
    let ruler = NSParagraphStyle.defaultParagraphStyle().mutableCopy() as! NSMutableParagraphStyle
    ruler.firstLineHeadIndent = 0.0
    ruler.
headIndent = indent
    ruler.
tabStops = [NSTextTab(textAlignment: NSTextAlignment.Left, location: indent, options: [:])]
    
return ruler
}

Scroll top top after setting text [UNSOLVED]

The best solution so far is not good enough. I don’t want to see the text in the action of scrolling. I want it scrolled when the view is displayed.

In didSet for each of the dependent properties:

      choreoTextView?.attributedText = dance?.richtextForMode(.Teach)

then:

override public func viewDidLayoutSubviews() {
    choreoTextView?.scrollRangeToVisible(NSMakeRange(0, 0))
}