SOPullUpView 1.1.0

SOPullUpView 1.1.0

ahmadalsofi 维护。



  • 作者
  • Ahmadalsofi

SOPullUpView

Version License Platform

安装

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

pod 'SOPullUpView'

基本用法

  1. pod 'SOPullUpView' 添加到您的 Podfile。

  2. 库 SOPullUpView 的主要内容。它定义了一个 SOPullUpControl 的实例,在该实例中,可以拖动名为 SOPullUpView 的 MainViewController 以上下移动,隐藏或显示内容。例如,定义 SOPullUpControl 并将数据源和初始化的视图分配给 PullUpViewController

      let pullUpController = SOPullUpControl()
      
      override func viewDidLoad() {
         super.viewDidLoad()
          pullUpController.dataSource = self
          pullUpController.setupCard(from: view)
       }
  3. 请确保主视图控制器将采用 SOPullUpViewDataSource

    • pullUpViewCollapsedViewHeight ...startViewHeightForPullUpViewController...

      例如,StartViewHeight 由以下代理调用确定

         func pullUpViewCollapsedViewHeight() -> CGFloat {
             return  100.0
           }
    • pullUpViewController ...UIViewController 作为主控制器的子控制器...

        func pullUpViewController() -> UIViewController {
           guard let vc = UIStoryboard(name: StoryBoardName, bundle: nil).instantiateInitialViewController() as? YourPullUpView else {return UIViewController()}
           vc.pullUpControl = self.pullUpController
           return vc
        }
    • pullUpViewExpandedViewHeight ...maximumHeightForPullUpViewController... (可选方法)

  4. 在 PullUpViewController 中定义一个 SOPullUpControl 的实例,从 ParentViewController 初始化

     var pullUpControl: SOPullUpControl? {
         didSet {
             pullUpControl?.delegate = self
         }
     }
  5. 最后,在 pullUpViewController 中采用 SOPullUpViewDelegate

    • pullUpViewStatus ...当视图展开和折叠时将触发 pull Up View 的状态...

         func pullUpViewStatus(_ sender: UIViewController, didChangeTo status: PullUpStatus) {
             switch status {
               case .collapsed:
               case .expanded:
            }
           }
    • pullUpHandleArea ...返回用户点击时会处理动作的视图,折叠和展开 pullUpViewController....

        func pullUpHandleArea(_ sender: UIViewController) -> UIView {
            return handleArea
        }

示例

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

作者

Ahmadalsofi,[email protected]

参考

Brain Advent

许可

SOPullUpView 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。