我有一個iphone應用程序中的自定義視圖,當條件滿足時,應該調暗屏幕並向用戶顯示一些輸入字段。iOS UIButton始終是透明的
我沒有問題禁用主控制和「調光」屏幕(只是一個UIView與alpha = 0.6),但是我在這上面顯示的控件總是似乎有一些透明度(我可以閱讀一些通過UIButton的文本),即使我將控件的alpha設置爲1.0並設置opaque = YES。我甚至嘗試在按鈕和覆蓋層之間放置一個額外的不透明層,它仍然是部分透明的。
作爲參考:(iOS的6.1)
UIView * overlay = [[UIView alloc] initWithFrame:parentView.frame];
overlay.backgroundColor = [UIColor blackColor];
overlay.alpha=0.6;
UIButton * button = [UIButton buttonWithType:UIButtonRoundedRect];
button.backgroundColor = [UIColor whiteColor];
button.alpha = 1.0;
button.opaque = YES;
[button setTitle:@"done" forState:UIControlStateNormal];
[button setFrame:CGRectMake(0.0,0.0,44.0,44.0)];
[overlay addSubview:button];
[parentView addSubview:overlay];
甚至與上面的代碼的按鈕是透明的。有誰知道爲什麼以及如何使按鈕不透明?
你的意思是說你得到的按鈕的alpha也是0.6。我是對吧? –