Last active
March 2, 2020 04:07
-
-
Save hkitago/e49b434992339e48d80d8e68bd537e37 to your computer and use it in GitHub Desktop.
Fullscreen WKWebView for SPA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// FullscreenWKWebView4SPA | |
// | |
// Created by Hiroyuki Kitago on 2017/10/26. | |
// Copyright © 2017年 Hiroyuki Kitago. All rights reserved. | |
// | |
import UIKit | |
import WebKit | |
class ViewController: UIViewController, WKNavigationDelegate { | |
let webview: WKWebView = WKWebView() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
webview.frame = view.bounds; | |
webview.navigationDelegate = self | |
webview.scrollView.bounces = false | |
webview.scrollView.showsVerticalScrollIndicator = false | |
webview.scrollView.showsHorizontalScrollIndicator = false | |
webview.scrollView.isScrollEnabled = false | |
if #available(iOS 11.0, *) { | |
webview.scrollView.contentInsetAdjustmentBehavior = .never | |
} | |
webview.autoresizingMask = [.flexibleWidth, .flexibleHeight] | |
view.addSubview(webview) | |
let url = Bundle.main.url(forResource: "index", withExtension: ".html")! | |
let request = URLRequest(url: url) | |
webview.load(request) | |
self.navigationController?.setNavigationBarHidden(true, animated: false) | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
// Dispose of any resources that can be recreated. | |
} | |
override var prefersStatusBarHidden: Bool { | |
return true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment