Reputation: 13020
How can i set the translucent property in QLPreviewController i have tried the below code but its not working
QLPreviewController *previewer = [[QLPreviewController alloc] init];
// Set data source
[previewer setDataSource:self];
[previewer setDelegate:self];
previewer.edgesForExtendedLayout = UIRectEdgeNone;
[previewer setCurrentPreviewItemIndex:index];
[self.navigationController.navigationBar setTranslucent:NO];
[self.navigationController setToolbarHidden:NO];
[[self navigationController] pushViewController:previewer animated:YES];
Thanks
Upvotes: 2
Views: 2616
Reputation: 1583
Swift 3 & 4 this works for me as of February 2018
import QuickLook
UINavigationBar.appearance(whenContainedInInstancesOf: [QLPreviewController.self]).setBackgroundImage(UIImage.init(color: primaryColor), for: .default)
this is the image with color func in an extension
extension UIImage {
//image with color
convenience init?(color: UIColor) {
let rect = CGRect(x: 0.0, y: 0.0, width: 1.0, height: 1.0)
UIGraphicsBeginImageContext(rect.size)
let path = UIBezierPath(rect: rect)
color.setFill()
path.fill()
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
self.init(cgImage: image!.cgImage!)
}
}
Upvotes: 2
Reputation: 2955
You can use this:
UINavigationBar *navBar = [UINavigationBar appearanceWhenContainedIn:[QLPreviewController class], nil];
[navBar setBackgroundImage:[UIImage imageNamed:@"navigation-bg-ios7.png"] forBarMetrics:UIBarMetricsDefault];
I've tried it and it works.
Upvotes: 3
Reputation: 2562
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];
Note: Only works in iOS7
Upvotes: 0