开发者

get window height/width in real-time

开发者 https://www.devze.com 2022-12-26 09:38 出处:网络
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

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

精彩评论

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

关注公众号