I’ve set an image for a button. Even though the image has a transparent background, there is always a white edge around the button. I’ve tried a lot of things (see codes below), how do I get rid of it?
[myButton setBackgroundImage:[UIImage imageNamed:@"button.png"] forState:UIControlStateNormal];
[myButton setBackgroundColor:[UIColor clearColor]];
[[myButton layer] setBackgroundColor:[[UIColor clearColor] CGColor]];
[[myButton layer] setBorderWidth:0];
I’m not allowed to upload pictures yet, but the result can be found here: https://docs.google.com/open?id=0B9d-ZrsbiU3IY2RPcXlKNlh1Q1U
As you can see, that white edge is very annoying.
You need to create a button of type
UIButtonTypeCustom.If you’re creating it programatically then use
buttonWithType:UIButtonTypeCustom. If you’re creating it in IB then select “Custom” as the type from the drop down.This will mean that the standard white is not drawn.