BottomHalfModal 1.1.1

BottomHalfModal 1.1.1

Masamichi Ueta 维护。




  • Mercari, Inc.

BottomHalfModal Platform iOS11+ License: MIT

BottomHalfModal是merpay中使用的可定制半模态UI。

BottomHaflModal

安装

Carthage

github "mercari/BottomHalfModal"

CocoaPods

pod "BottomHalfModal"

使用

BottomHalfModal可以将任何类型的《UIVIewController》作为内容呈现。所呈现的视图控制器需要遵守《SheetContentHeightModifiable》协议,并定义《sheetContentHeightToModify》,这是半模态的高度。然后在《viewDidAppear》中调用《adjustFrameToSheetContentHeightIfNeeded()`。

import BottomHalfModal

class XXXXViewController: SheetContentHeightModifiable {
    var sheetContentHeightToModify: CGFloat = 320
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        adjustFrameToSheetContentHeightIfNeeded()
    }
}

然后,调用《presentBottomHalfModal(_ viewControllerToPresent: UIViewController, animated: Bool, completion: (() -> Void)?)》来显示内容。

    let vc = XXXXViewController()
    presentBottomHalfModal(vc, animated: true, completion: nil)

如果您想在BottomHalfModal中使用《UINavigationController》,请使用《BottomHalfModalNavigationController》。它处理推送和弹出导航中的内容高度更新。

    let vc = XXXXViewController()
    let nav = BottomHalfNavigationController(rootViewController: vc)
    presentBottomHalfModal(nav, animated: true, completion: nil)

如果您支持多种设备方向,请也在《viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator)》中调用《adjustFrameToSheetContentHeightIfNeeded()`。

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    super.viewWillTransition(to: size, with: coordinator)
    adjustFrameToSheetContentHeightIfNeeded(with: coordinator)
}

示例

基本
Basic
TableView
TableView
导航
Navigation
StickyButton
StickyButton
输入
Input

贡献

在向Mercari提交贡献之前,请仔细阅读CLA。在任何情况下,通过提交您的贡献,您被视为接受并同意受CLA条款和条件的约束。

https://www.mercari.com/cla/

许可

版权所有 2019 Mercari, Inc.

遵循MIT许可证。