这可以很容易地用UITextView和UIButton完成。只需简单地将UITextView的你要显示的内容在屏幕上,使得它的屏幕的全框的大小,改变背景颜色为黑色背景.6
[UIColor colorWithRed: 0 withGreen: 0 withBlue: 0 withAlpha: .6];
背景Alpha然后把按钮作为顶层的子视图,使其成为屏幕的全帧,并将其设置为0.设置按钮的操作以隐藏文本视图和按钮。
例子:
UITextView* textview = [[UITextView alloc] initWithFrame:self.view.frame];
[textview setText: @"Text here"];
[textview setBackgroundColor: [UIColor colorWithRed: 0 withGreen: 0 withBlue: 0 withAlpha: .6]];
[textview setTextColor: [UIColor whiteColor]];
[self.view addSubview: textview];
UIButton* btn = [[UIButton alloc] initWithFrame:self.view.frame];
[btn setAlpha:0];
[btn addTarget:self action:@selector(method) forEvent:UIControlEventTouchUpInside];
[self.view addSubview: btn];
你可能要检查的addTarget:方法;我不确定这些是否是我头顶的正确参数。
[相关问题](http://stackoverflow.com/questions/849458/transparent-modal-view-on-navigation-controller/859215#859215),虽然有点过时 – user 2013-04-29 16:12:52