0

我正在尝试将相机视图中的条形图着色为黑色。到目前为止,以下方法均无效。我要更改 2 个视图,第一个带有相机图标和“取消”,第二个带有“重拍”和“使用”按钮。有任何想法吗?

- (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];
    }
}
4

2 回答 2

2

使用UIAppearance. 查阅文档

于 2012-07-03T15:11:38.603 回答
0

您可以使用UIImagePickerController showsCameraControlsandcameraOverlayViewUIImagePickerController. 将该showsCameraControls值设置为 NO 将隐藏UIImagePickerController除相机视图之外的所有内容。cameraOverlayView允许您将自己的视图置于相机视图之上。然后,您可以使用您自己的底栏、您自己的按钮……创建一个视图,并将其放在 UIImagePicker 的前面。

UIView *overlayView = [[UIView alloc] init];
/* Customize overlayView with your bottomBar and button */
UIImagePickerController imagePickerController = [[UIImagePickerController alloc] init];
/* Configure your UIImagePickerController for picture and/or video */
imagePickerController.showsCameraControls = NO; //Must be set to NO if you want to use the cameraOverlayView
imagePickerController.cameraOverlayView = overlayView;
overlayView = nil;

不幸的是,如果你想使用这种方法,你必须重新创建原始UIImagePickerController视图的所有按钮(闪光模式按钮、选项按钮……),并且你必须创建自己的导航控制器才能进入视图使用“重拍”和“使用”按钮。然而,它的实现非常简单。

于 2012-07-16T09:35:34.523 回答