简体   繁体   中英

NSWindow with custom shadow

I want to draw a custom shadow on an NSWindow-Object.

Is there a way to do this by passing an own NSShadow-Object to NSWindow? Or a (private) method, where I can put my own drawing code?

Thanks,

Don't. You shouldn't alter the look of the window. Changing the look of UI is only allowed for Apple. Normal apps should use the standard one.

That said, there's a way, if you really insist on doing that. You can't just attach an NSShadow , unfortunately. Also, as far as I understand, there's no private method which draw the shadow. That's done by the Window Server, not by the app.

But you can ask the window server not to add the shadow. Have you noticed that in the Interface Builder, there's an option suppressing the shadow of a given window? That corresponds to the property hasShadow of an NSWindow .

After suppressing the shadow, you just need to draw everything by yourself. A nice sample code that does the custom window drawing is available at ADC , so have a look at it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM