BottomCardView 0.3.0

BottomCardView 0.3.0

Evgeny Gulkov 维护。



  • Evgeny Gulkov

BottomCardView

BottomCardView 是一个基于 UIView 并使用 Swift 编写的视图

并使用 POP 进行动画

alt-text

Platform Swift5 CocoaPods Carthage License

需求

BottomCardView 使用 Swift 5 编写。兼容 iOS 11.0 及以上版本。

安装

Cocoapods

pod 'BottomCardView'

Carthage

github "EvgeniyGulkov/BottomCardView"

使用方法

设置

您可以使用此视图作为简单的 UIView,使用界面构建器或以编程方式进行添加

示例

import BottomCardView

class ViewController: UIViewController, BottomCardViewDelegate {

    @IBOutlet weak var bottomCardView: BottomCardView!
    @IBOutlet weak var tableViewInBottom: UITableView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setupBottomCard()
    }

    func setupBottomCard() {

        /// add point (value from bottom)
        bottomCardView.addPoint(value: 400)
        
        /// if you want to use top of your screen or top safe area inset as top point,
        /// you should add point greater or equal your screen height. for example .infinity
        bottomCardView.addPoint(value: .infinity)

        /// set minimum point from bottom
        bottomCardView.minPoint = 30

        /// set delegate
        bottomCardView.delegate = self

        /// if you want to scroll BottomCardView when scrollView inside
        /// is scrolled to end, you should add it with following method
        bottomCardView.addScroll(for: tableViewInBottom)
    }

您可以通过编程方式更改高度

bottomCardView.changeHeight(value: 100, animation: .basic(duration: 0.2)) { animation, complete in

}

/// change by point index
bottomCardView.moveToPoint(index: 1, animation: .spring) { animation, complete in

}

您还可以选择动画类型

  • 无(无动画)
  • 弹簧(默认参数的弹簧动画)
  • 基本(无弹簧的动画,但可以更改持续时间)

为更改弹簧动画的默认属性

bottomCardView.bounces = 4
bottomCardView.animationSpeed = 20

设置安全距离内边距

override func viewDidLayoutSubviews() {
    bottomCardView.insets = view.safeAreaInsets
}

跟踪高度

您可以使用专用代理方法跟踪高度和位置

func bottomCardView(progressDidChangeFromPoint index: Int, toPoint nextIndex: Int, withProgress progress: CGFloat)

func bottomCardView(viewHeightDidChange height: CGFloat)

作者

@EvgeniyGulkov, [email protected]

许可协议

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