A simple view controller for navigating web pages using WKWebView. iOS 8+
- A browser-like view controller to support web pages navigation in your Swift app.
- Supports back-forward navigation and page refresh action.
- Supports back-forward swipe gestures.
- Has built-in activity indicators (both progress view and activity indicator).
Just grab two files GDWebViewController.swift
and GDWebViewNavigationToolbar.swift
into your project.
You can download GDWebBrowserClient
project as well to see how it can be used.
####Properties
weak var delegate: GDWebViewControllerDelegate?
An object to serve as a delegate which conforms to GDWebViewNavigationToolbarDelegate protocol.
var progressIndicatorStyle: GDWebViewControllerProgressIndicatorStyle = .Both
The style of progress indication visualization. Can be one of four values: .ActivityIndicator, .ProgressView, .Both, .None
var allowsBackForwardNavigationGestures: Bool
A Boolean value indicating whether horizontal swipe gestures will trigger back-forward list navigations. The default value is false.
var showsToolbar: Bool
A boolean value if set to true shows the toolbar; otherwise, hides it.
var showsStopRefreshControl: Bool
A boolean value if set to true shows the refresh control (or stop control while loading) on the toolbar; otherwise, hides it.
var toolbar: GDWebViewNavigationToolbar
The navigation toolbar object (read-only).
####Methods
func loadURLWithString(URLString: String)
Navigates to an URL created from provided string.
func loadURL(URL: NSURL, cachePolicy: NSURLRequestCachePolicy = .UseProtocolCachePolicy, timeoutInterval: NSTimeInterval = 0)
Navigates to the URL.
func showsToolbar(show: Bool, animated: Bool)
Shows or hides toolbar.
####GDWebViewControllerDelegate Methods
@objc protocol GDWebViewControllerDelegate {
optional func webViewController(webViewController: GDWebViewController, didChangeURL newURL: NSURL?)
optional func webViewController(webViewController: GDWebViewController, didChangeTitle newTitle: NSString?)
optional func webViewController(webViewController: GDWebViewController, decidePolicyForNavigationAction navigationAction: WKNavigationAction, decisionHandler: (WKNavigationActionPolicy) -> Void)
optional func webViewController(webViewController: GDWebViewController, decidePolicyForNavigationResponse navigationResponse: WKNavigationResponse, decisionHandler: (WKNavigationResponsePolicy) -> Void);
optional func webViewController(webViewController: GDWebViewController, didReceiveAuthenticationChallenge challenge: NSURLAuthenticationChallenge, completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential!) -> Void);
}
Notice:
You must do import WebKit
if you use last three methods from GDWebViewControllerDelegate
description.
####Properties
var toolbarTintColor: UIColor?
The tint color to apply to the toolbar button items.
var toolbarBackgroundColor: UIColor?
The toolbar's background color.
var toolbarTranslucent: Bool
A Boolean value that indicates whether the toolbar is translucent (true) or not (false).
Published under MIT license. If you have any feature requests, please create an issue. Smart pull requests are also welcome.