Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change button color on UIImagePickerController navigation bar?

I have managed to change the color of the navigation bar but the color of the buttons is still black. Is there any way to change the color of the buttons as well? See below image.

UPDATE: Sorry had to remove the image due to copy right issue.

like image 951
Ankit Srivastava Avatar asked Sep 17 '12 09:09

Ankit Srivastava


3 Answers

It is not possible without your custom image.

but you should change the tint color as soon as you create the navigation controller:

 UIImagePickerController *pickerImg = [[UIImagePickerController alloc] init];
pickerImg.navigationBar.barStyle = UIBarStyleBlackOpaque; // Or whatever style.
// or
pickerImg.navigationBar.tintColor = [UIColor whateverColor];
like image 102
Jerry Thomsan Avatar answered Sep 28 '22 18:09

Jerry Thomsan


you can hide the naviagtion bar,and create a custom navagtion bar by using imageview and place 2 buttons on it.By doing this you can change the image/color of buttons as well as image view also as per your requirement.

for hiding navigation bar:

 self.navigationController.navigationBarHidden=YES;

then in XIB : create a view of 44 height ,place imageview on it and place 2 button and 1 label on it.

Hopely this will solve your problem.

like image 41
megha Avatar answered Sep 28 '22 16:09

megha


@Ankit You can try getting the subviews from the navigation bar and then set the desired color . I used this approach to set the color of cancel button on the search bar . The size of the cancel button is 48*30 and you can use the subviews array to set the desired color. I am not sure but this may do the job . Below is the code i used to set the color of cancel button on the search bar.

NSArray *arrySearchSubviews=[searchBarFrnds subviews];
for (UIButton *btn in arrySearchSubviews) 
{
   CGRect rect=btn.frame;
    NSLog(@"width %f",rect.size.width);
    NSLog(@"height %f",rect.size.height);
    if (rect.size.width==48 ) 
    {
        [btn setTintColor:[UIColor colorWithRed:0 green:0.403f blue:0.4f alpha:1.0f]];
    }
}
like image 23
Singh Avatar answered Sep 28 '22 17:09

Singh