测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最后发布 | 2017年2月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 Takeshi Watanabe 维护。
PTPopupWebView 是一个简单且有用的 iOS WebView,它可以弹出,并具有许多自定义项目。
iOS 8.0
PTPopupWebView 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
use_frameworks!
pod "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)
弹出 | 展开 | 滑动 |
---|---|---|
![]() | ![]() | ![]() |
淡入/淡出 | 无 |
---|---|
![]() | ![]() |
自定义动作按钮可以通过 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()
自定义动作 |
---|
![]() |
详细代码请参考示例应用程序的源代码。
彩色标题 | 隐藏标题 |
---|---|
![]() | ![]() |
彩色按钮 | 自定义图片按钮 | 隐藏按钮 |
---|---|---|
![]() | ![]() | ![]() |
全屏 | 带边框 |
---|---|
![]() | ![]() |
渡边武志,[email protected]
PTPopupWebView 在MIT授权协议下可用。有关更多信息,请参阅LICENSE文件。