调整NSSplitView的大小
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了调整NSSplitView的大小相关的知识,希望对你有一定的参考价值。
This provides a nice split view resizing method with a minimum size restraint. You HAVE to specify MIN_LEFT_PANE_W for this to work.
// http://www.wodeveloper.com/omniLists/macosx-dev/2003/May/msg00261.html // grab the splitviews float dividerThickness = [sender dividerThickness]; // get the different frames NSRect newFrame = [sender frame]; NSRect leftFrame = [left frame]; NSRect rightFrame = [right frame]; // change in width for this redraw int dWidth = newFrame.size.width - oldSize.width; // ratio of the left frame width to the right used for resize speed when both panes are being resized float rLeftRight = (leftFrame.size.width - MIN_LEFT_PANEL_W) / rightFrame.size.width; // resize the height of the left leftFrame.size.height = newFrame.size.height; leftFrame.origin = NSMakePoint(0,0); // resize the left & right pane equally if we are shrinking the frame // resize the right pane only if we are increasing the frame // when resizing lock at minimum width for the left panel if(leftFrame.size.width <= MIN_LEFT_PANEL_W && dWidth < 0) { rightFrame.size.width += dWidth; } else if(dWidth > 0) { rightFrame.size.width += dWidth; } else { leftFrame.size.width += dWidth * rLeftRight; rightFrame.size.width += dWidth * (1 - rLeftRight); } rightFrame.size.width = newFrame.size.width - leftFrame.size.width - dividerThickness; rightFrame.size.height = newFrame.size.height; rightFrame.origin.x = leftFrame.size.width + dividerThickness; [left setFrame:leftFrame]; [right setFrame:rightFrame]; }
以上是关于调整NSSplitView的大小的主要内容,如果未能解决你的问题,请参考以下文章