Search code examples
iosavfoundationuipickerviewcontroller

iOS7+ What's the best practice in Image Picking (>2014)


I have a project where I select and display images in a collection view. I've been using a UIImagePickerController, but I'm bumping into design limitations.

I really just want to format the picker controller (size and colors), so that it fits the design of the rest of the project. Many questions on SO on this topic reply with "move to AVFoundation". However, AVFoundation seems unwieldy when performing this kind of task.

Hence my question.

UPDATE:

Adding the code that calls the image picker.. I'd like to be able to control the picker frame size.

- (IBAction)useCameraRoll:(id)sender {
    NSLog(@"%s", __FUNCTION__);
    if ([UIImagePickerController isSourceTypeAvailable:
         UIImagePickerControllerSourceTypeSavedPhotosAlbum])
    {
        UIImagePickerController *imagePicker =
        [[UIImagePickerController alloc] init];
        imagePicker.delegate = self;
        imagePicker.sourceType =
        UIImagePickerControllerSourceTypePhotoLibrary;
        imagePicker.mediaTypes = @[(NSString *) kUTTypeImage];
        imagePicker.allowsEditing = NO;

        //imagePicker.navigationBar.tintColor = [UIColor redColor];
        [[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];
        [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
        [[UINavigationBar appearance] setFrame:CGRectMake(0,0,300, 300)];
        [[UICollectionView appearanceWhenContainedIn:[UIImagePickerController class], nil] setBackgroundColor:[UIColor greenColor]];

        [self presentViewController:imagePicker animated:YES completion:nil];
        _newMedia = NO;

    }

}

Solution

  • You could customize the UINavigationController / UINavigationBar by using appearance:

    [[UINavigationBar appearance] setBarTintColor:[UIColor blueColor]];
    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
    

    The same could be done for the toolbar etc. to customize your look.