Webview
public class Webview
-
Initializes a Webview
Declaration
Swift
public init(_ debug: Bool = false)
Parameters
debug
Debug mode flag.
-
Runs the webview. This is blocks the main thread
Declaration
Swift
public func run()
-
Navigates the webview to the specified URL.
Declaration
Swift
public func navigate(_ url: String) -> Webview
Parameters
url
The URL to navigate to.
Return Value
The current instance of Webview for chaining.
-
Sets the HTML content of the webview.
Declaration
Swift
public func setHtml(_ html: String) -> Webview
Parameters
html
The HTML content to set.
Return Value
The current instance of Webview for chaining.
-
Sets the title of the webview.
Declaration
Swift
public func setTitle(_ title: String) -> Webview
Parameters
title
The title to set.
Return Value
The current instance of Webview for chaining.
-
Sets the title of the webview.
Declaration
Swift
public func setSize(_ width: Int32, _ height: Int32, _ hint: SizeHint) -> Webview
Parameters
title
The title to set.
Return Value
The current instance of Webview for chaining.
-
Injects & executes JavaScript code into every new page in the webview. It is guaranteed that this will execute before
window.onload
Declaration
Swift
public func inject(_ js: String) -> Webview
Parameters
js
The JavaScript code to inject.
Return Value
The current instance of Webview for chaining.
-
Evaluates JavaScript code in the webview. Evaluation happens asynchronously. The result of the JavaScript is ignored. Execute a function bound with
bind
if you need two way communication.Declaration
Swift
public func eval(_ js: String) -> Webview
Parameters
js
The JavaScript code to evaluate.
Return Value
The current instance of Webview for chaining.
-
Binds a swift function to a named JavaScript function in the global scope.
Declaration
Swift
public func bind(_ name: String, _ callback: @escaping JSCallback) -> Webview
Parameters
name
The name that will be used to invoke the function in JavaScript.
callback
The swift function to execute when the JS function is invoked
Return Value
The current instance of Webview for chaining.
-
Unbinds a function and removes it from the global JavaScript scope Parameter name: The name of the JavaScript function to unbind.
Declaration
Swift
public func unbind(_ name: String) -> Webview
-
Destroys the webview and closes the window. Once a Webview has been destroyed it cannot be used. Returns: The current instance of Webview for chaining.
Declaration
Swift
public func destroy() -> Webview
-
Terminates the main loop and closes the window. This function is thread safe. Returns: The current instance of Webview for chaining.
Declaration
Swift
public func terminate() -> Webview