4

I'm adding an NSProgressIndicator to my NSMenuItem (with a custom view). It works fine, but it has a weird square around it:

White square around progress indicator

Here is my code:

// In my @interface declaration:
NSProgressIndicator *_spinner;

...

// In initWithFrame:
_spinner = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0, 0, 20, 20)];
[_spinner setBezeled:NO];
[_spinner setTranslatesAutoresizingMaskIntoConstraints:NO];
[_spinner setControlSize:NSMiniControlSize];
[_spinner setStyle:NSProgressIndicatorSpinningStyle];
[_spinner sizeToFit];
[self addSubview:_spinner];

I am not sure why this is happening. Does anyone have any idea?

Thanks.

pkamb
  • 33,281
  • 23
  • 160
  • 191
David Murray
  • 541
  • 5
  • 19

2 Answers2

2

Me too faced the same issue, The problem is not with the progress indicator, it is with the associated superview of the progress indicator.

The Solution is,

Just change the Appearance property value of the View to "Aqua" instead of "Inherited Aqua". Refer the attached image.


Refer this Image

Jeba Moses
  • 809
  • 8
  • 25
-3

Try making the background transparent and making the view not opaque

[_spinner setOpaque:NO];
[_spinner setBackgroundColor:[NSColor clearColor]];
Fernando Mazzon
  • 3,562
  • 1
  • 19
  • 21