PopItUp 1.1.0

PopItUp 1.1.0

Fritzgérald MUISEROUX 维护。




PopItUp 1.1.0

PopItUp

Carthage compatible GitHub release Swift 4.0 License: MIT CocoaPods Compatible

PopItUp 是一个微型框架,为 UIViewControllers 添加新的方法来帮助您展示可弹出的控制器,并具有与系统弹出相同的视觉效果。

它是如何工作的?

PopItUp 使用 iOS 8 中引入的新模态样式来展示被展示的视图控制器。

默认情况下,弹出大小通过自动布局确定,这意味着在正确的约束下,您不必担心弹出大小。

截图

Exemple

要求

  • iOS 9.0+
  • Xcode 9.0+
  • Swift 4.0+

安装

CocoaPods

如果尚未安装,请使用以下命令安装 cocoaPods

$ gem install cocoapods

构建 PopItUp 需要 CocoaPods 1.1.0+ 版本

要使用 CocoaPods 将 PopItUp 集成到您的 Xcode 项目中,请在 Podfile 中指定它

platform :ios, '9.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'PopItUp'
end

这将安装 Popup 的最新版本

使用以下命令应用您的配置

$ pod install

用法

显示 popup 视图控制器

import PopItUp


presentPopup(TestPopupViewController(), animated: true, completion: nil)

关闭 popup

因为我们使用的是标准的 iOS 模态系统,您只需调用 dismiss(animated:completion:) 方法即可

dismiss(animated: true, completion: nil)

自定义 popup 显示

presentPopup 方法包含多个参数,用于自定义最终结果

  • backgroundStyle:显示在 popup 后面的背景。可以是颜色或模糊效果。
  • constraints:应用于 popup 的约束列表。
  • transitioning:应用给视图的过渡方式。
  • autoDismiss:如果为 true,则 popup 可以通过在边界外点击来关闭,否则为 false
presentPopup(TestPopupViewController(),
             animated: true,
             backgroundStyle: .blur(.dark), // present the popup with a blur effect has background
             constraints: [.leading(20), .width(220)], // fix leading edge and the width
             transitioning: .slide(.left), // the popup come and goes from the left side of the screen
             autoDismiss: false, // when touching outside the popup bound it is not dismissed
             completion: nil)