Skip to content
This repository was archived by the owner on Jun 4, 2025. It is now read-only.

Commit bb01061

Browse files
committed
make webview full screen on iphoneX
1 parent 1d8d2a3 commit bb01061

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

FullScreenWebView.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// FullScreenWebView.swift
3+
// Pods-WeLoop_Example
4+
//
5+
// Created by Henry Huck on 24/04/2019.
6+
//
7+
8+
import UIKit
9+
import WebKit
10+
11+
class FullScreenWKWebView: WKWebView {
12+
override var safeAreaInsets: UIEdgeInsets {
13+
return .zero
14+
}
15+
}

WeLoop.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'WeLoop'
11-
s.version = '0.2.1'
11+
s.version = '0.2.2'
1212
s.summary = 'Integrate WeLoop to your iOS project'
1313

1414
s.description = <<-DESC

WeLoop/Classes/WeLoopViewController.swift

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,29 @@ class WeLoopViewController: UIViewController {
2828
return config
2929
}()
3030

31+
override var prefersStatusBarHidden: Bool {
32+
return true
33+
}
34+
3135
override func viewDidLoad() {
3236
super.viewDidLoad()
3337
configureWebview()
3438
}
35-
36-
override var prefersStatusBarHidden: Bool {
37-
return true
38-
}
3939

4040
private func configureWebview() {
41-
let webView = WKWebView(frame: view.bounds, configuration: self.configuration)
41+
let webView = FullScreenWKWebView(frame: view.bounds, configuration: self.configuration)
4242
view.addSubview(webView)
4343
webView.allowsLinkPreview = false
44+
webView.scrollView.delegate = self
45+
webView.scrollView.bounces = false
46+
47+
webView.translatesAutoresizingMaskIntoConstraints = false
48+
webView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true;
49+
webView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true;
50+
webView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true;
51+
webView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true;
52+
53+
webView.scrollView.showsVerticalScrollIndicator = false
4454
self.webView = webView
4555
loadWeLoop()
4656
}
@@ -73,3 +83,9 @@ extension WeLoopViewController: WKScriptMessageHandler {
7383
}
7484
}
7585
}
86+
87+
extension WeLoopViewController: UIScrollViewDelegate {
88+
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
89+
return nil
90+
}
91+
}

0 commit comments

Comments
 (0)