我想在相機視圖中爲黑色條形變色。以下方法迄今尚無法運作。有兩個視圖需要更改,第一個是攝像頭圖標和「取消」,第二個是「重拍」和「使用」按鈕。有任何想法嗎?如何更改UIImagePicker中的欄顏色?
- (void)openCamera {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.navigationBar.barStyle = UIBarStyleBlackOpaque;
picker.toolbar.barStyle = UIBarStyleBlackOpaque;
picker.navigationBar.tintColor = [UIColor blackColor];
[self presentModalViewController:picker animated:NO];
}
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
UIImagePickerController *picker = (UIImagePickerController *)navigationController;
if((picker)&&(picker.sourceType == UIImagePickerControllerSourceTypeCamera))
{
picker.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
picker.navigationController.toolbar.barStyle = UIBarStyleBlackOpaque;
picker.navigationBar.tintColor = [UIColor blackColor];
}
}
非常好,能夠改變所有UIToolbars和UINavigationBars不幸的是UIImagePicker似乎使用別的東西。 –
嗯......有趣。我的印象是,它使用了'UINavigationController',它有自己的'UINavigationBar' ... – Jasarien
你有沒有嘗試過將'bar style設置爲'UIBarStyleDefault'並使用'tintColor'? – Jasarien