Skip to content

Instantly share code, notes, and snippets.

@sasikanth513
Created July 22, 2018 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sasikanth513/5c6013973efcc1b621ed49602f76683f to your computer and use it in GitHub Desktop.
Save sasikanth513/5c6013973efcc1b621ed49602f76683f to your computer and use it in GitHub Desktop.
Mac os swift app to add horizontal scroll to the text view
class ViewController: NSViewController {
@IBOutlet weak var scrollView: NSScrollView!
@IBOutlet var textView: NSTextView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
scrollView.hasHorizontalScroller = true
textView.maxSize = NSMakeSize(CGFloat(Float.greatestFiniteMagnitude), CGFloat(Float.greatestFiniteMagnitude))
textView.isHorizontallyResizable = true
textView.textContainer?.widthTracksTextView = false
textView.textContainer?.containerSize = NSMakeSize(CGFloat(Float.greatestFiniteMagnitude), CGFloat(Float.greatestFiniteMagnitude))
}
override var representedObject: Any? {
didSet {
// Update the view, if already loaded.
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment