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().
| Property | Descrption | Default |
|---|---|---|
| URL | URL of the page you want to display. | |
| title | The specified title instead of web page's title. If valuse is set nil, displays web page's title. | |
| content | The specified contents instead of web resources. | |
| style | View style. Detail of style parameter, see PTPopupWebViewStyle. |
Methods
| Method Name | Arguments | Return Type | Descrption |
|---|---|---|---|
| addExternalLinkPattern | String | Self | Add URL pattern to open in iOS default behavior. |
| addExternalLinkPattern | PTPopupWebViewExternalLinkPattern | Self | Add URL pattern to open in iOS default behavior. |
| addButton | PTPopupWebViewButton | Self | Add button to popupView |
| close | Void | Close the popup view. |
PTPopupWebViewExternalLinkPattern
Enum of PTPopupWebViewExternalLinkPattern is defined as below.
| Definition | Value | Description |
|---|---|---|
| URLScheme | "^(?!https?:\/\/)" | links not starts with "http://","https://" |
| iTunes | "\/\/itunes\.apple\.com\/" | iTunes related links |