PTPopupWebView 0.4.0

PTPopupWebView 0.4.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2017年2月
SwiftSwift 版本3.0
SPM支持 SPM

Takeshi Watanabe 维护。



  • 作者
  • Takeshi Watanabe

PTPopupWebView

PTPopupWebView 是一个简单且有用的 iOS WebView,它可以弹出,并具有许多自定义项目。 弹窗

需求

iOS 8.0

安装

PTPopupWebView 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

use_frameworks!
pod "PTPopupWebView"

使用方法

使用此库有两种方法:

  1. 使用 PTPopupWebViewController,当用作模态弹出时非常简单。
  2. 直接使用 PTPopupWebView

详细信息请参阅演示和 类参考

类参考

类参考

演示

要运行示例项目,请先克隆仓库,然后从 Example 目录运行 pod install

简介

最初,弹出网页的代码如下。

let popupvc = PTPopupWebViewController()
popupvc.popupView.URL(string: "https://github.com/")
popupvc.show()

弹出过渡样式

弹出出现/消失样式可以按以下方式更改:

// Pop Style (default transition style. 1st parameter is animation duration, and 2nd is using spring animation flag.)
let popupvc = PTPopupWebViewController()
    .popupAppearStyle(.Slide(.Bottom, 0.4, true))
    .popupDisappearStyle(.Slide(.Bottom, 0.4, true))
// Spread Style (parameter is animation duration)
let popupvc = PTPopupWebViewController()
    .popupAppearStyle(.Spread(0.25))
    .popupDisappearStyle(.Spread(0.25))
// Slide Style (1st parameter is direction, 2nd is animation duration, and 3rd is using spring animation flag.)
let popupvc = PTPopupWebViewController()
    .popupAppearStyle(.Slide(.Bottom, 0.4, true))
    .popupDisappearStyle(.Slide(.Bottom, 0.4, true))
// Fade Style (parameter is animation duration)
let popupvc = PTPopupWebViewController()
    .popupAppearStyle(.Fade(0.25))
    .popupDisappearStyle(.Fade(0.25))
// Without Transition Style
let popupvc = PTPopupWebViewController()
    .popupAppearStyle(.None)
    .popupDisappearStyle(.None)
弹出 展开 滑动
Pop Spread Slide
淡入/淡出
Fade Introduction

自定义动作

自定义动作按钮可以通过 PTPopupWebViewButton 的 handler 属性执行用户定义的操作。

popupvc.popupView
    // add custom action button
    .addButton(
        PTPopupWebViewButton(type: .Custom)
            .title("custom"))
            .handler() {
                // write handler code here

                // this demo show alert view
                let alert:UIAlertController = UIAlertController(title: "Custom Action",message: popupvc.popupView.webView.title!,preferredStyle: UIAlertControllerStyle.Alert)
                alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
                popupvc.presentViewController(alert, animated: true, completion: nil)
            }
    // add close button
    .addButton(PTPopupWebViewButton(type: .Close).title("close"))
popupvc.show()
自定义动作
Custom Action

视图样式

详细代码请参考示例应用程序的源代码。

标题样式
彩色标题 隐藏标题
Colored Title Hide Title
按钮样式
彩色按钮 自定义图片按钮 隐藏按钮
Colored Button Custom Image Button Hide Button
其他样式
全屏 带边框
FullScreen With Frame

作者

渡边武志,[email protected]

授权协议

PTPopupWebView 在MIT授权协议下可用。有关更多信息,请参阅LICENSE文件。