I am showing a pdf file in WKWebView in IOS swift, and it showing fine. I am loading pdf file from server. But some part of file is being hidden behind top navigation bar. I want to add margin at top of WKWebView. Here is my current code.
let myBlog = file
let url = NSURL(string: myBlog)
let request = NSURLRequest(url: url! as URL)
// init and load request in webview.
webView = WKWebView(frame: self.view.frame)
webView.navigationDelegate = self
webView.load(request as URLRequest)
self.view.addSubview(webView)
// webView.translatesAutoresizingMaskIntoConstraints = false
// webView.addConstraints([NSLayoutConstraint(item: webView, attribute: .height, relatedBy: .equal, toItem: view, attribute: .height, multiplier: 1, constant: 0)])
self.view.addSubview(sv)
let pdfVC = UIViewController()
pdfVC.view.addSubview(webView)
pdfVC.title = "File"
self.navigationController?.pushViewController(pdfVC, animated: true)
Here the commented code is how I am trying to add margin and not working.