Webview
public class Webview
-
Initializes a Webview
Declaration
Swift
public init(_ debug: Bool = false)Parameters
debugDebug 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) -> WebviewParameters
urlThe 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) -> WebviewParameters
htmlThe 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) -> WebviewParameters
titleThe 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) -> WebviewParameters
titleThe 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.onloadDeclaration
Swift
public func inject(_ js: String) -> WebviewParameters
jsThe 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
bindif you need two way communication.Declaration
Swift
public func eval(_ js: String) -> WebviewParameters
jsThe 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) -> WebviewParameters
nameThe name that will be used to invoke the function in JavaScript.
callbackThe 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
Webview Class Reference