我有一個應用程序,我需要在所有應用程序上顯示自定義狀態欄。爲此,我到didFinishLaunchingWithOptions:
方法寫這個代碼在通過窗口或導航控制器添加視圖時,約束條件發生變化?
self.window.windowLevel = UIWindowLevelStatusBar;
然後在我的viewController創建了(0,0,寬度,20)幀圖的圖,並添加某些元素到它。
我嘗試添加的窗口上面的這一觀點是這樣
AppDelegate *appdelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[self.statusview setTranslatesAutoresizingMaskIntoConstraints:YES];
[appdelegate.window addSubview:statusview];
但它在左上角獲取添加,而無需任何元素。但是,當我設置寬度並再次添加元素時,它就會顯示出來。
有人能幫助我嗎?
我添加了寬度約束,當我添加此行statusview.frame = CGRectMake(0,0,self.view.frame.size.width,20);其中的元素不顯示 – hacker
更改自我。 view.frame.size.width爲[uiscreen mainscreen] .bounds.size.width,再試一次。 –
相同result.added正確但內部元素丟失 – hacker