简体   繁体   English

改变NSScrollView中NSScroller的高度

[英]Change the height of NSScroller in NSScrollView

I have a NSScrollView, which has NSClipView and vertical/horizontal NSScrollers in it.我有一个 NSScrollView,其中有 NSClipView 和垂直/水平 NSScrollers。
Now I want to change the height of the vertical scroller so that it occupies only the top half portion of the scroll view.现在我想改变垂直滚动条的高度,让它只占据滚动视图的上半部分。 I can not change the height from the size inspector.我无法通过尺寸检查器更改高度。 I tried changing the frame.我试着改变框架。 It didn't work either.它也没有用。
Can someone help me get through this problem?有人可以帮我解决这个问题吗? Thankyou in advance!先感谢您!

Since OS X 10.10, NSScrollView has a scrollerInsets property which should be able to position the scroller differently than the scroll view itself, if wanted.从 OS X 10.10 开始,NSScrollView 有一个scrollerInsets属性,如果需要,它应该能够以不同于滚动视图本身的方式 position 滚动条。

Small world.小世界。

I ended up cooking a special component for the 8th pure SwiftUI/FRP incarnation of WhatSize.app There are things Swift UI can't really do, so you have to wrap NSView objects as NSViewRepresentable and now they are available to a pure SwiftUI app.我最终为 WhatSize.app 的第 8 个纯 SwiftUI/FRP 化身制作了一个特殊组件。有些事情 Swift UI 确实做不到,因此您必须将 NSView 对象包装为 NSViewRepresentable,现在它们可用于纯 SwiftUI 应用程序。

scrollView.scrollerInsets = .init(top: 0.0, left: 0.0, bottom: 14.0, right: 0.0)

So the vertical scroll bars do not stomp over the drag and column resize icon on the bottom in yellow.所以垂直滚动条不会踩到底部黄色的拖动和列调整大小图标。

This allows WhatSize to display data just as Finder's "as Columns" does.这使得 WhatSize 可以像 Finder 的“as Columns”一样显示数据。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM