2010-06-04 62 views
0

我所有的視圖都有一個藍色導航欄,但是當我希望用戶選擇一張照片時,UIImagePicker是黑色的。我嘗試使用UIBarStyleDefault將UIImagePickerController的導航欄設置爲藍色,但它不適用於我,顏色仍然是黑色。我嘗試過其他的UIBarStyle,比如UIBarStyleBlack和UIBarStyleOpaque,但是它不會改變選擇器的導航欄。這裏是我的代碼將UIImagePicker導航欄樣式更改爲藍色

// Let the user choose a new photo. 
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; 
    imagePicker.delegate = self; 
    imagePicker.navigationBar.barStyle = UIBarStyleDefault; 
    [self presentModalViewController:imagePicker animated:YES]; 
    [imagePicker release]; 

回答

3

我認爲沒有辦法改變它。所以我的解決方案是使用色彩表來獲取顏色代碼中默認導航欄的顏色:紅色代碼,藍色代碼,綠色代碼。然後我使用方法

imagePicker.navigationBar.tintColor = [UIColor colorWithRed:redCode green:greenCode blue:blueCode alpha:0.1];

UINavigationBar tintColor

UIColor Reference

+0

@ iOS7它將改變字體。 – yershuachu 2013-11-04 14:17:01

7

的另一種方法是使用

- (void)navigationController:(UINavigationController *)navigationController 
    willShowViewController:(UIViewController *)viewController 
       animated:(BOOL)animated { 
navigationController.navigationBar.barStyle = UIBarStyleDefault; 
} 

那就是UINavigationControllerDelegate protocol的istance方法。

這會將導航欄樣式更改爲藍色。

0

使用委託來改變它爲我工作。