簡體   English   中英

在iOS 6.0中更改UIButton的邊緣顏色

[英]Change the edge color for UIButton in iOS 6.0

出於某種原因,iOS 6繪制標准RoundedRect的方式有所不同。 選中或突出顯示時,舊的圓形按鈕(頂部)的邊緣為黑色。 相同的代碼在iOS 6.0(如下)中以白色作為邊緣繪制按鈕。 我找不到在iOS 5中將顏色更改回黑色的方法。

代碼很簡單

_loadButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[_loadButton setFrame:CGRectMake(200, 130, 115, 40)];
[_loadButton setTitle:@"Load Game" forState:UIControlStateNormal];

在此處輸入圖片說明

在此處輸入圖片說明

嘗試這個:

[button.layer setBorderColor:(__bridge CGColorRef)([UIColor blackColor])];

對於圓形邊緣:

button.layer.cornerRadius = 8;

您還可以添加以下內容:

[button.layer setMasksToBounds:YES];
[button.layer setBorderWidth:1.0f];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM