最近在寫項目的時候出現(xiàn)了個問題,就是使用UIImagePickerController獲取圖庫照片后,發(fā)現(xiàn)statusBar的顏色從白色變成了黑色(我整個項目都是白色)
然后點擊頭像進入相冊選擇照片的時候變成這樣.
顯然是UIImagePickerController的navigationbar在作怪便脊,在調(diào)用UIImagePickerController的地方,加上如下代碼:
#pragma mark -UINavigationControllerDelegate
-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
? ? ? ? ?//跳轉(zhuǎn)到UIImagePickerController的時候使statusBar得顏色還是白色
? ? ? ? ? if ([ navigationController isKindOfClass:[UIImagePickerController class] ]) {
? ? ? ? ? ? ? ? ? navigationController.navigationBar.barStyle = ? ? ? ? ? ? ? ? ?UIStatusBarStyleLightContent;
? ? ? ? ? }
}
在網(wǎng)上看到只有這種方法:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
? ? ? ? ? ?// bug fixes: UIIMagePickerController使用中偷換StatusBar顏色的問題
? ? ? ? ? if ([navigationController isKindOfClass:[UIImagePickerController class]] ) {
? ? ? ? ? ? ? ? ? ? [[UIApplication sharedApplication] setStatusBarHidden:NO];
? ? ? ? ? ? ? ? ? ? [[UIApplication sharedApplication] ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
? ? ? ? ? }
}