LHPopover
示例
要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install
。
所需条件
安装
LHPopover 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中:
pod 'LHPopover'
使用
要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install
。
简单
let startPoint = CGPoint(x: self.view.frame.width - 60, y: 55)
let aView = UIView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 180))
let popover = Popover()
popover.show(aView, point: startPoint)
自定义
@IBOutlet weak var leftBottomButton: UIButton!
let width = self.view.frame.width / 4
let aView = UIView(frame: CGRect(x: 0, y: 0, width: width, height: width))
let options = [
.type(.up),
.cornerRadius(width / 2),
.animationIn(0.3),
.blackOverlayColor(UIColor.red),
.arrowSize(CGSize.zero)
] as [PopoverOption]
let popover = Popover(options: options, showHandler: nil, dismissHandler: nil)
popover.show(aView, fromView: self.leftBottomButton)
需求
- iOS 8.0+
- Swift 4
如果您使用 Swift 3.0,请尝试 Popover 1.1.0。如果您使用 Swift 2.2 或 2.3,请尝试 Popover 0.9.1。
安装
CocoaPods(iOS 8+)
Popover可以通过CocoaPods获取。安装方法是在您的Podfile
中添加以下行
use_frameworks!
pod "Popover"
Carthage(iOS 8+)
您可以使用Carthage通过将其添加到您的Cartfile
中安装Popover
github "corin8823/Popover"
手动安装
Popover所需类文件位于此仓库根目录下的Classes文件夹中,如下所示
Popover.swift
自定义
枚举
case arrowSize(CGSize)
case animationIn(NSTimeInterval)
case animationOut(NSTimeInterval)
case cornerRadius(CGFloat)
case sideEdge(CGFloat)
case blackOverlayColor(UIColor)
case overlayBlur(UIBlurEffectStyle)
case type(Popover.PopoverType)
case color(UIColor)
case dismissOnBlackOverlayTap(Bool)
case showBlackOverlay(Bool)
属性
arrowSize: CGSize = CGSize(width: 16.0, height: 10.0)
animationIn: NSTimeInterval = 0.6
animationOut: NSTimeInterval = 0.3
cornerRadius: CGFloat = 6.0
sideEdge: CGFloat = 20.0
popoverType: PopoverType = .down
blackOverlayColor: UIColor = UIColor(white: 0.0, alpha: 0.2)
overlayBlur: UIBlurEffect?
popoverColor: UIColor = UIColor.white
致谢
许可
Popover 可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE 文件。