0

I have a view with several subviews (NSButton, NSTextField, NSPopUpButton) and a NSImageView with a spinner icon which should be displayed on top of the other views while data is retrieved from the web.

To display the NSImageView on top I have set

imageViewSpinner.wantsLayer = true
imageViewSpinner.layer?.backgroundColor = NSColor.windowBackgroundColor.cgColor

The problem is, that the focus borders and PopUpButtons are still accessible/shining through the NSImageView (see attached video).

To solve this, I could iterate over all the other subviews and set them to "isHidden" or "disabled" but I wonder, if there is a cleaner solution to this problem, for example defining the NSImageView as topmost layer without things getting through?

video

John
  • 139
  • 1
  • 9

1 Answers1

1

You could put all of the other views inside of one container view and hide that.

You can also use a tab-less tab view to programmatically switch between view sub-hierarchies. (That basically achieves the same thing. It's better when there are more than 2 views to manage.)

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154
  • Yeah I thought about that, but I was wondering if this is really the only solution to this problem. Thanks for your idea – John Feb 20 '20 at 15:38