當重疊添加以下代碼中的AppDelegate實現者功能didFinishLaunchingWithOptions狀態欄使用ECSlidingViewController
如果([[[的UIDevice currentDevice] systemVersion]的floatValue]> = 7){
[application setStatusBarStyle:UIStatusBarStyleLightContent];
self.window.clipsToBounds =YES;
self.window.frame = CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidChangeStatusBarOrientation:)
name:UIApplicationDidChangeStatusBarOrientationNotification
object:nil];
}
以及這個函數被調用:
- (void)applicationDidChangeStatusBarOrientation:(NSNotification *)notification
{
int a = [[notification.userInfo objectForKey: UIApplicationStatusBarOrientationUserInfoKey] intValue];
int w = [[UIScreen mainScreen] bounds].size.width;
int h = [[UIScreen mainScreen] bounds].size.height;
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
UIDeviceOrientation orientationa = [[UIDevice currentDevice] orientation];
if (orientation==4)
{
self.window.frame = CGRectMake(20,0,w-20,h+20);
}else if(orientation==1)
{
self.window.frame = CGRectMake(0,20,w,h);
}else
{
self.window.frame = CGRectMake(-20,0,w+20,h+20);
}
}
這適用於獲取狀態欄即使在旋轉時也不重疊,但是當點擊一個按鈕後,它會向後端發出更改並重疊,直到它再次旋轉,任何人都知道爲什麼會發生這種情況?我懷疑這可能與ECSlidingViewController有關?
http:// stackoverf low.com/questions/17074365/status-bar-and-navigation-bar-appear-over-my-views-bounds-in-ios-7 – the1pawan
請參閱http://stackoverflow.com/a/20093515/1545180以及這http://stackoverflow.com/a/19025547/1545180 – Ganapathy