使用 Swift 创建一个带有模糊背景的弹出视图!我会不断添加更多动画来展示弹出视图!以下是界面示例(来自演示应用程序)
JKBlurPopup
通过 CocoaPods 提供。要安装它,只需将以下行添加到 Podfile 中:“pod "JKBlurPopup"
如果您不想使用 CocoaPods,只需将文件 JKBlurPopup/JKBlurPopup.swift 从中复制到您的 Xcode 项目中。
要运行示例项目,克隆仓库,然后首先在 JKBlurPopupDemo 目录中运行 pod install。这将运行示例程序,展示 JKBlurPopup 的外观和功能。
class ExampleJKBlurPopup: JKBlurPopup {
override init(frame: CGRect) {
super.init(frame: frame)
// 自定义宽高
//setWidthHeight(400, 300)
// 自定义圆角大小
//setJKCorner(15)
// 自定义背景模糊效果
//setJKBlurEffect(.Light)
let close = UIButton(type: .Custom)
close.setTitle("点我关闭", forState: .Normal)
close.setTitleColor(UIColor.greenColor(), forState: .Normal)
close.frame = CGRectMake(0, 185, 300, 30)
close.addTarget(self, action: #selector(btnClose), forControlEvents: .TouchUpInside)
contentView.addSubview(close)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
func btnClose() {
dismiss()
}
}
实际上没有任何要求。只要您导入了 UIKit,自旋器就会处理其他所有事情。
此项目从 SwiftPopup 修改而来,添加了一些 API 来自定义弹出视图的大小、阴影和模糊背景。 https://github.com/ehowlsla/SwiftyPopup
JKBlurPopup
在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。