开发者

custom view minimum size

开发者 https://www.devze.com 2023-01-31 06:26 出处:网络
Is there a way to enforce minimum size for a Custom View (NSView)? I know with window one can just set the mini开发者_如何学Cmum size, but there are no such setting for custom view.

Is there a way to enforce minimum size for a Custom View (NSView)? I know with window one can just set the mini开发者_如何学Cmum size, but there are no such setting for custom view.

Is it possible to subclass NSView for this purpose?

The reason I need this is because I have the following structure. Now if I use the split view bar and push it all the way to the top, and bring it back down again, the table view will fill the entire upper portion of the split view, hiding all other components. If I can specify the minimum size of the upper custom view, I can prevent this from happening.

SplitView
-> Custom View
-> -> Table View
-> -> ...
-> Custom View
-> -> ...

Thanks


In this case, what you want to do is constrain the sizes of the split view's subviews. The easy way to do this is to use Rainer Brockerhoff's RBSplitView, which can be configured to do what you want within Interface Builder. The code is dual-licensed under both the CC-BY-2.5 and the MIT licenses. The hard way is to name some object the delegate of the split view and implement the appropriate NSSplitViewDelegate methods, such as splitView:constrainMinCoordinate:ofSubviewAt:.

0

精彩评论

暂无评论...
验证码 换一张
取 消