How can I darken everything that is displayed in one NSView?

Background: My application has a main window that contains several smaller NSView objects, each of which contains several different controls, shortcuts, images, etc. One of these views (and it all contains) is disabled in response to the given flag. When the flag is set, I automatically disable and block all controls built into this NSView .

Question: I would like to know how to darken a disabled NSView . The effect I'm looking for will be something like drawing a transparent black box 50% on top of a disabled NSView . The background and all controls will still be visible, but the colors will be a darker shade. Is there an easy way to do this?

+3
source share
1 answer

CoreAnimation in 10.5 should provide an easy way to place a translucent layer above the view. You can create a black layer before the view, with an opacity of 0%. When you want to darken the view, set the black layer opacity to 50% and the image will be darkened.

+2
source

Source: https://habr.com/ru/post/892089/


All Articles