Xcode 如何去除图像按钮周围的白色边缘?
我已经为按钮设置了一个图像。即使图像具有透明背景,按钮周围也始终有白色边缘。我已经尝试了很多东西(见下面的代码),我如何摆脱它Xcode 如何去除图像按钮周围的白色边缘?,xcode,imagebutton,Xcode,Imagebutton,我已经为按钮设置了一个图像。即使图像具有透明背景,按钮周围也始终有白色边缘。我已经尝试了很多东西(见下面的代码),我如何摆脱它 [myButton setBackgroundImage:[UIImage imageNamed:@"button.png"] forState:UIControlStateNormal]; [myButton setBackgroundColor:[UIColor clearColor]]; [[myButton layer] setBackgroundColor:
[myButton setBackgroundImage:[UIImage imageNamed:@"button.png"] forState:UIControlStateNormal];
[myButton setBackgroundColor:[UIColor clearColor]];
[[myButton layer] setBackgroundColor:[[UIColor clearColor] CGColor]];
[[myButton layer] setBorderWidth:0];
我还不允许上传图片,但结果可以在这里找到:
正如您所看到的,白色边缘非常烦人。您需要创建一个类型为
uibuttonypecustom
的按钮
如果您是以编程方式创建它,请使用按钮,其类型为:UIButtonTypeCustom
。如果您在IB中创建它,那么从下拉列表中选择“Custom”作为类型
这意味着不会绘制标准白色