0

カメラビューのバーを黒くしようとしています。これまでのところ、以下のアプローチはどれも機能しませんでした。変更したいビューは 2 つあります。1 つ目はカメラ アイコンと「キャンセル」、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

You can use the UIImagePickerController showsCameraControls and cameraOverlayView to use a custom view over the UIImagePickerController. Setting the showsCameraControlsvalue to NO will hide everything on the UIImagePickerController but the camera view. cameraOverlayView allow you to put your own view over the camera view. You can then create a view with your own bottom bar, your own buttons, ... and put it in front of the 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;

Unfortunately, with this method you must recreate all the buttons of the original UIImagePickerController view (the flash mode button, the options button, ...) if you want to use them, and you have to create your own navigation controller to go to the view with the "retake" and "use" buttons. However it's very simple to implement.

于 2012-07-16T09:35:34.523 に答える