NSWindow resize control covered by NSView
I have an NSView subclass sized to fit a regular NSWindow window (right to the edges).
The view draws a background color, and when the app runs, it covers u开发者_如何学运维p the standard window resize control in the bottom right hand corner. You can still resize the window by dragging the corner.
If I resize my view so it doesn't quite go to the edge of the window, it's clear that the resize control is being drawn, but being overlapped by my view.
Anyone know of a way to fix this? Will I have to draw the resize control myself?
Here's a screenshot showing what I mean.
You will either have to draw the grip yourself or knock out the lower-right corner of your background. Given that your view is flush with the edges of the window, I'd just draw it myself and be done with it.
Only trouble is I believe you'll have to handle drag-to-resize yourself if you do it this way (don't quote me, though). If so, you'll have to create an NSTrackingArea for that corner and handle drags in that area as window frame changes (size and origin).
So I got it working by creating a layer with an image of the handle, and positioning it in the bottom right corner of the layer of the view. I don't have to implement the dragging myself - it just works.
Use a backed layer versus a hosted layer. A hosted layer is typically for something really custom and applied to a borderless window in my experience.
精彩评论