0

我已经为按钮设置了图像。即使图像具有透明背景,按钮周围总是有白边。我已经尝试了很多东西(见下面的代码),我该如何摆脱它?

[myButton setBackgroundImage:[UIImage imageNamed:@"button.png"] forState:UIControlStateNormal];
[myButton setBackgroundColor:[UIColor clearColor]];

[[myButton layer] setBackgroundColor:[[UIColor clearColor] CGColor]];
[[myButton layer] setBorderWidth:0];

我还不允许上传图片,但可以在这里找到结果:https ://docs.google.com/open?id=0B9d-ZrsbiU3IY2RPcXlKNlh1Q1U

如您所见,那个白色边缘非常烦人。

4

1 回答 1

0

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.

于 2012-04-17T19:49:54.713 回答