0

I am trying to create a simple browser but the browser overlaps with operator and battery info icons on the top. I want to add 20px padding or margin on top of the app.

enter image description here This is the only code I have in the viewController.swift

import UIKit
import WebKit

class ViewController: UIViewController {

@IBOutlet var containerView : UIView! = nil

var webView: WKWebView?


override func loadView() {


    super.loadView()

    self.webView = WKWebView()
    self.view = self.webView!
}

override func viewDidLoad() {
    super.viewDidLoad()

    var url = NSURL(string:"http://nyt.com")
    var req = NSURLRequest(URL:url!)
    self.webView!.loadRequest(req);

}


override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
 } }
kig
  • 163
  • 1
  • 9
  • Is there any reason you can't make the view itself smaller by 20px? Or put it into a wrapper UIView that is full size, and the WKWebView 20px smaller? – Son of a Beach Dec 20 '16 at 21:37
  • That's what I am trying to do, but since I am loading the view programmatically I don't know how to do this. – kig 40 secs ago edit – kig Dec 20 '16 at 21:54
  • Do the answers here help? ... http://stackoverflow.com/questions/18775874/ios-7-status-bar-overlaps-the-view (scroll past the first answer for programatic solutions - Objective C though, sorry). Google "uiview overlap status bar" for more suggestions – Son of a Beach Dec 20 '16 at 21:55
  • Here's another interesting work around (Objective-C again, but you get the idea): http://stackoverflow.com/questions/18886195/ios-7-status-bar-overlapping-ui – Son of a Beach Dec 20 '16 at 21:57
  • See this case similar to yours ... I hope it helps you: https://stackoverflow.com/questions/45421548/ios-wkwebview-status-bar-padding – R.Park Aug 13 '18 at 16:12

0 Answers0