0

I am having a mac app.

In which, I am creating a NSButton programmatically.

Here is my code below.

NSButton *myButton = [[NSButton alloc] initWithFrame:NSMakeRect(263, 265, 125, 148)];
        [[cleanNow contentView] addSubview: myButton];
        [myButton setImage:[NSImage imageNamed:@"scanbutton"]];
        [myButton setButtonType:NSMomentaryChangeButton];
        [myButton setWantsLayer:NO];
 [myButton setTarget:self];
        [myButton setAction:@selector(ScannowPressed:)];

so it shows like below image

I want an image only. Not that white background.

I know there is some silly mistake I am making in button type or somewhere. I have tried a lot but no luck.

Also, is it possible in mac OS X that we can show button in front lie we show in ios as bringsubviewtofront???

Please help me on this.

Manthan
  • 3,856
  • 1
  • 27
  • 58
  • And the "scanbutton" image contains a transparent background? – Droppy Jun 22 '15 at 07:39
  • Have you tried changing the button background colour to `clearColor`? – Droppy Jun 22 '15 at 07:44
  • [[myButton cell] setBackgroundColor:[NSColor clearColor]]; Already tried with this... – Manthan Jun 22 '15 at 07:46
  • Google for template images. That's what you need to find info on (and it's poorly documented. As usual mostly in WWDC videos) also, DO NOT put text in an image. If you want text set the title of the button. If you want a particular font, add the font to your project and reference it properly. – uchuugaka Jun 22 '15 at 08:49

0 Answers0