如何自定义QLPreviewController的navBar和工具栏tintColor

jun*_*dhu 3 iphone uitoolbar uinavigationcontroller ipad ios

QLPreviewController * preview = [[QLPreviewController alloc] init];
preview.dataSource = self;
preview.currentPreviewItemIndex = sender.tag;
preview.editing= YES; 
[self presentModalViewController:preview animated:YES];
[preview release];
Run Code Online (Sandbox Code Playgroud)

这两行对我不起作用.所以在写这些线之前要小心.

[preview.tabBarController.tabBar setTintColor:[UIColor blackColor]];
[preview navigationController].navigationBar setTintColor: [UIColor blackColor]];
Run Code Online (Sandbox Code Playgroud)

问题截图在这里

wib*_*obm 12

从iOS5开始,您可以基于实例,全局或特定容器类包含主题控件.由于iOS6以前的子类化QLPreviewController方法设置了UINavigationBar的tintColor停止工作.

考虑以下其中一项作为与iOS5和iOS6兼容的变通方法的示例:

QLPreviewController中包含的任何UINavigationBar:

[[UINavigationBar appearanceWhenContainedIn:[QLPreviewController class], nil]
        setTintColor:[UIColor blackColor]];
Run Code Online (Sandbox Code Playgroud)

或全局设置应用程序中所有UINavigationBar实例的tintColor:

 [[UINavigationBar appearance] setTintColor:[UIColor blackColor]];
Run Code Online (Sandbox Code Playgroud)

这个策略适用于UITabBarController.