当我在文本视图中启用水平滚动时,内容将在“垂直标尺”视图上方滚动。理想情况下,它不应与行号视图重叠。
这是它的样子
为了实现水平滚动,我在NSTextView上编写了一个扩展
public extension NSTextView {
func wrapText(_ isWrapped: Bool) {
guard let scrollView = enclosingScrollView else { return }
scrollView.hasHorizontalScroller = !isWrapped
isHorizontallyResizable = !isWrapped
let width = isWrapped ? Int(scrollView.contentSize.width) : Int.max
maxSize = NSSize(width: width, height: Int.max)
textContainer?.size = NSSize(width: width, height: Int.max)
textContainer?.widthTracksTextView = isWrapped
}
}
也
textView.enclosingScrollView!.hasVerticalRuler = true