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
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.
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!)
}
}
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];
注意:仅适用于iOS7
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.