Displaying text in a NSScrollView (Swift)

前端 未结 7 1518
醉酒成梦
醉酒成梦 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
    
    0 讨论(0)
提交回复
热议问题