【发布时间】:2013-09-16 15:56:15
【问题描述】:
我在 iphone 应用程序中有一个自定义视图,当满足条件时,它应该使屏幕变暗并向用户显示一些输入字段。
我没有问题禁用主控件和“调暗”屏幕(只是一个 alpha=0.6 的 UIView),但是我在上面显示的控件似乎总是有一些透明度(我可以阅读一些文本通过 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。我说得对吗?
标签: iphone ios objective-c uibutton transparency