Displaying text in a NSScrollView (Swift)

前端 未结 7 1578
醉酒成梦
醉酒成梦 2020-12-10 05:14

Just started to learn Swift and created a little macOS app in which I want to use a NSScrollView to display an attributed String. I’ve tried:

@I         


        
7条回答
  •  天涯浪人
    2020-12-10 05:53

    @IBOutlet weak var scrollView: NSScrollView!
    

    The documentView of the NSScrollView is an NSTextView, so in Swift you can use the following:

    let textView : NSTextView? = scrollView?.documentView as? NSTextView
    textView?.string = text
    

提交回复
热议问题