开发者

get window height/width in real-time

it's possible to get window width or height while resizing it? not on start or end of resizing (viewWillStartLive开发者_StackOverflow中文版Resize, viewDidEndLiveResize), but in real time?


Yes. Set an object as the window's delegate and implement either of these delegate methods:

- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize;
- (void)windowDidResize:(NSNotification *)notification;

The -windowDidResize: method is sufficient if you want to keep some other window synchronized to the size of your window as it is called with every small size change, not at the end of the resize operation.


If your window's content view resizes with the window, and you're willing to make that view a custom NSView subclass, then you can override -[NSView resizeSubviewsWithOldSize:] and check self.bounds there.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜