Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to customize QLPreviewController's navBar and toolbar tintColor

QLPreviewController * preview = [[QLPreviewController alloc] init];
preview.dataSource = self;
preview.currentPreviewItemIndex = sender.tag;
preview.editing= YES; 
[self presentModalViewController:preview animated:YES];
[preview release];

These two lines does not work for me. so be careful before writing these lines.

[preview.tabBarController.tabBar setTintColor:[UIColor blackColor]];
[preview navigationController].navigationBar setTintColor: [UIColor blackColor]];

Problem Screenshot here

like image 635
junaidsidhu Avatar asked Dec 03 '22 01:12

junaidsidhu


2 Answers

Since iOS5 you can theme controls based on instance, globally or when contained by specific container classes. Since iOS6 the former method of subclassing QLPreviewController to set the tintColor of the UINavigationBar stopped working.

Consider one of the following as an example of a workaround that is compatible with iOS5 and iOS6:

Any UINavigationBar contained within a QLPreviewController:

[[UINavigationBar appearanceWhenContainedIn:[QLPreviewController class], nil]
        setTintColor:[UIColor blackColor]];

or globally set the tintColor of all UINavigationBar instances within your app with:

 [[UINavigationBar appearance] setTintColor:[UIColor blackColor]];

This same strategy works with the UITabBarController.

like image 89
wibobm Avatar answered Jan 14 '23 09:01

wibobm


set style of UINavigationController with this line..

self.navigationController.navigationBar.barStyle = UIBarStyleBlack;

and for change the color of TabBar just Add the below code in viewWillAppear of your class

CGRect frame = CGRectMake(0.0, 0.0, self.view.bounds.size.width, 48);
UIView *v = [[UIView alloc] initWithFrame:frame];
[v setBackgroundColor:[UIColor colorWithRed:0.1 green:0.2 blue:0.6 alpha:0.8]];
[v setAlpha:0.5];
[[self.tabBarController tabBar] insertSubview:v atIndex:0];
[v release];
like image 37
Paras Joshi Avatar answered Jan 14 '23 08:01

Paras Joshi