How to make a transparent NSView subclass handle mouse events?

后端 未结 7 1581
清歌不尽
清歌不尽 2021-02-04 10:31

The problem

I have a transparent NSView on a transparent NSWindow. The view\'s drawRect: method draws some content (NSIma

相关标签:
7条回答
  • 2021-02-04 11:15

    You can do:

    NSView* windowContent = [window contentView];
    [windowContent setWantsLayer:YES]
    

    Making sure that the background is transparent:

    [[windowContent layer] setBackgroundColor:[[NSColor clearColor] CGColor]];
    

    Another option would be to add a transparent background image that fills the contentView.

    0 讨论(0)
提交回复
热议问题