2012-04-17 121 views
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

正如你所看到的,白邊是很煩人的。

回答

0

您需要創建一個類型爲UIButtonTypeCustom的按鈕。

如果您以編程方式創建它,然後使用buttonWithType:UIButtonTypeCustom。如果您使用IB創建它,然後從下拉列表中選擇「自定義」作爲類型。

這將意味着標準白色未被繪製。

相關問題