0

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;

    }

}
Jay Bhalani
  • 4,142
  • 8
  • 37
  • 50
ICL1901
  • 7,632
  • 14
  • 90
  • 138

1 Answers1

2

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.

Logan
  • 52,262
  • 20
  • 99
  • 128
  • That's terrific.. Is there any way to change the background color of the picker itself, and especially, the frame size? – ICL1901 Dec 31 '14 at 20:38
  • Background Color: I'm not positive if this will work, but try: `[[UICollectionView appearanceWhenContainedIn:[UIImagePickerController class], nil] setBackgroundColor:[UIColor greenColor]];` I'm curious myself, so let me know if this does the trick. – Logan Dec 31 '14 at 20:43
  • For frame size, are you talking about the size of the entire view controller, or the size of the cells? For the cells, I'm not sure if you have a lot of control over that. For the view controller, if you're adding its view as a subview, you should be able to size it like any other view. – Logan Dec 31 '14 at 20:45
  • Hmm. thanks for the answers! I'm adding some code to my question. Perhaps I'm calling the picker incorrectly. – ICL1901 Dec 31 '14 at 20:46
  • Ahh, I see, are you trying to set the navigation bar's frame? That's not going to work, I don't think you can do that without getting a bit hacky. Does the background color work? One note is that you don't need to call the appearance methods each time (I don't think it will hurt anything as you have it implemented currently though). I often add a `style` method in my app delegate and call it once on app launch. This styles the rest of the app. – Logan Dec 31 '14 at 20:50
  • Right, just playing with the appearance methods. I'll move them when I get this working ... The background color didn't work - but I'll play with that too. The main issue now is the frame. The collection view is presented as a nice modal about 300 x 300. The picker takes over the whole window, and I'm trying to make the picker the same reduced size. The current frame size is really ugly on a iPad... And I appreciate your helping me... – ICL1901 Dec 31 '14 at 20:55
  • Not sure I fully understand, are you saying that when you present the picker, it's full screen but you don't want that? Have you tried making it a formsheet? `picker.modalPresentationStyle = UIModalPresentationFormSheet;` – Logan Dec 31 '14 at 21:00