Class PTPopupWebView

April 1, 2016 ยท View on GitHub

PTPopupWebView is UIView contains webview, title, and buttons.

Appearance of view can be changed by style class, PTPopupWebViewStyle.

The button's style and action can be changed by setting class PTPopupWebViewButton. Also, button's action can be changed, the web navigations which is predefined actions, and the custom action can use.

Usage

PTPopupWebView is instantiated with initializer init(), or access to PTPopupWebViewController's property popupView

let popupView = PTPopupWebView()
// or
let popupvc = PTPopupWebViewController()
let popupView = popupvc.popupView

All properties are able to set by method chain propertyName().

popupView
    .URL(NSURL(string: "https://github.com/"))
    .style(style)

The method addExternalLinkPattern() is used to add URL pattern to open in iOS default behavior, and the method addButton() is used to add buttons.

popupView
    .addExternalLinkPattern(.iTunes)
    .addExternalLinkPattern("^test:\\/\\/")
    .addButton(button)

Show PTPopupWebView are able to be added to view when directly use PTPopupWebView, or PTPopupWebViewController's method show(). And close are able to be used the method close().

// show popup
view.addSubview(popupView) // directly use PTPopupWebView
// or
popupvc.show()

// close popup
popup.close()

Properties

All properties are able to set by method chain propertyName().

PropertyDescrptionDefault
URLURL of the page you want to display.
titleThe specified title instead of web page's title. If valuse is set nil, displays web page's title.
contentThe specified contents instead of web resources.
styleView style. Detail of style parameter, see PTPopupWebViewStyle.

Methods

Method NameArgumentsReturn TypeDescrption
addExternalLinkPatternStringSelfAdd URL pattern to open in iOS default behavior.
addExternalLinkPatternPTPopupWebViewExternalLinkPatternSelfAdd URL pattern to open in iOS default behavior.
addButtonPTPopupWebViewButtonSelfAdd button to popupView
closeVoidClose the popup view.

PTPopupWebViewExternalLinkPattern

Enum of PTPopupWebViewExternalLinkPattern is defined as below.

DefinitionValueDescription
URLScheme"^(?!https?:\/\/)"links not starts with "http://","https://"
iTunes"\/\/itunes\.apple\.com\/"iTunes related links