2010-01-17 118 views

回答

0

如果你想創建類似UIAlertView的效果,我認爲你不能這樣做。您可能會在http://bugreporter.apple.com處向Apple提交功能增強請求。

+0

這是可行的,只需使用UIWindow即可。我用我使用的方法添加了一個答案。 – Sahil 2010-04-25 03:38:46

2

你能做的最好的事情是與隱藏狀態欄:

[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO] 

,並再次顯示它時,你需要它。

你可以基本上removeFromSuperview任何時候你想刪除視圖。

+1

該API已被棄用。替換是'setStatusBarHidden:withAnimation:'。 – ThomasW 2013-07-31 10:39:32

6

我正在爲如何做這個很長一段時間做鬥爭!終於找到它了:)關鍵是你的新窗口windowLevel設置爲真高,所以它活在所有其他窗口/視圖/狀態欄等頂級:

UIWindow *keyWin = [UIApplication sharedApplication].keyWindow; 
UIWindow *hudWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0.0f, 0.0f, keyWin.frame.size.width, keyWin.frame.size.height)]; 
hudWindow.backgroundColor = [UIColor blackColor]; 
hudWindow.alpha = 0.60; 
[hudWindow setWindowLevel:10000.0f]; 
[hudWindow setHidden:NO]; 

享受!

+0

我挖了一點,發現windowLevel屬性有一些常量表示某些級別: const UIWindowLevel UIWindowLevelNormal; const UIWindowLevel UIWindowLevelAlert; const UIWindowLevel UIWindowLevelStatusBar; 我發現UIWindowLevelStatusBar的竅門。 – Sahil 2010-04-20 00:56:22

+0

請注意,如果您在應用程序啓動時調用'keyWindow',則值可能爲零。最好使用[[UIScreen mainScreen]邊界]來獲得窗口框架。 – ThomasW 2013-08-02 10:18:48

+0

當鍵盤在屏幕上時,這不起作用。 – RaffAl 2014-03-25 14:04:48

0

不錯,但我做了這兩個改變。將UIWindowLevel添加到1.0仍然隱藏狀態欄,我不知道爲什麼。

self.windowLevel = UIWindowLevelStatusBar+2.0f; 

self.userInteractionEnabled = NO; 

設置狀態欄userInteractionEnabled屬性爲NO將確保您的滾動視圖會滾動,當有人在此狀態欄水龍頭頂部。