【发布时间】:2012-02-22 02:45:26
【问题描述】:
我有一个 UIViewController 派生类,我想做的是有一个不透明的子视图,而它的父视图(主 UIViewController.view)有 50% 的透明度。
在控制器类的 viewDidLoad 上,我设置了视图和子视图的 alpha 值。但是,我看到的是基本视图和子视图都是半透明的。有没有办法避免这种情况发生?
// Class declaration
@interface MyViewControllerClass : UIViewController
{ }
@property (nonatomic, strong) IBOutlet UIView *contentView;
@end
// Class implementation
- (void)viewDidLoad
{
// I want the main view to be a transparent overlay
[self.view setBackgroundColor:[UIColor lightGrayColor]];
[self.view setAlpha:0.5];
// This is the subview I want to look normal
[self.contentView setAlpha:1.0];
[self.contentView setOpaque:NO];
[super viewDidLoad];
}
【问题讨论】:
标签: iphone ios5 uiviewcontroller