Class PTPopupWebViewButton

April 1, 2016 ยท View on GitHub

PTPopupWebViewButton is the button settings for PTPopupWebView.

Usage

PTPopupWebViewButton is instantiated with initializer init(type:).

// button with close action
let button = PTPopupWebViewButton(type: .Close)

// button with open link action
let button = PTPopupWebViewButton(type: .Link(NSURL(string:"https://github.com/")))

Properties (except type property) are able to set by method propertyName().

// button with custom action
let button = PTPopupWebViewButton(type: .Custom)
    .title("Custom Action")
    .backgroundColor(UIColor(red:76/255, green:175/255, blue:80/255, alpha:1))
    .foregroundColor(UIColor.whiteColor())
    .disabledColor(UIColor.lightGrayColor())
    .font(UIFont.boldSystemFontOfSize(16))
    .image(UIImage(named:"demo")?.imageWithRenderingMode(.AlwaysTemplate))
    .handler(){
        print("Demo Action Done!!")
    }

Adding a button to PTPopupWebView, use the addButton method.

let popupvc = PTPopupWebViewController()
let button = PTPopupWebViewButton(type: .Close)
popupvc.popupView.addButton(button);

Properties

Properties (except type property) are able to set by method propertyName().

Property NameTypeDescrptionDefault
typePTPopupWebViewButtonTypeButton's type, to specify by initializer init(type:).
titleStringButton's title.""
backgroundColorUIColor?Button's background color.
foregroundColorUIColor?Button's foreground color.
disabledColorUIColor?Button's foreground color when button is disabled
fontUIFont?Button's font
imageUIImage?Button's custom image
handler(() -> ())?Button's custom action. If the botton (type .Custom) is tappped, this handler will be called.

Methods

Method NameReturn TypeDescrption
useDefaultImageSelfSet the default image to image property.

PTPopupWebViewButtonType

Enum of PTPopupWebViewButtonType is defined as below.

DefinitionArgumentsDescription
CloseButton with action of close popup.
LinkNSURL?Button with action of open link.
LinkCloseNSURL?Button with action of open link and close popup.
BackButton with action of web navigation of "back".
ForwardButton with action of web navigation of "forward".
ReloadButton with action of web navigation of "reload".
CustomButton with custom action.