這可以很容易地用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