0
我使用以下代碼在appDelegate類中創建了我的狀態欄。在AppDelegate實現後隱藏自定義狀態欄視圖
UIView *statusBarView = [[UIView alloc] initWithFrame:CGRectMake(0,0,320, 20)];
theView.backgroundColor = customGrayColor;
[self.window.rootViewController.view addSubview:statusBarView];
現在我想動態地將它隱藏在viewCOntrollers之一中。我隱藏了導航欄和狀態欄。
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[self.navigationController setNavigationBarHidden:YES];
我可以看到狀態欄已被隱藏,因爲所有文本都隱藏了,但只是灰色的視圖不會隱藏。
和問題範圍的iOS 7
好主意。讓我快速嘗試一下。 – CalZone
如果我創建了一個屬性AppDelegate,並在我的VC中創建了一個Appdelegate對象,如下所示:'AppDelegate * delegateObj =(AppDelegate *)[[UIApplication sharedApplication] delegate];'。我無法訪問自定義屬性。你能否澄清我需要如何在應用程序委託類中創建屬性? – CalZone
@CalZone,你需要在AppDelegate.h文件中設置屬性:'@property(nonatomic,readonly,strong)UIView * statusBarView;'用於訪問它:'delegateObj.statusBarView'。 –