BottomCard 0.5.0

BottomCard 0.5.0

Evgeny Gulkov维护。



  • 作者
  • Evgeny Gulkov

BottomCard

BottomCard是一个基于UIView,用Swift编写的视图

并使用POP进行动画

alt-text alt-text

Platform Swift5 CocoaPods Carthage License

要求

BottomCard使用Swift 5编写。兼容iOS 11.0及以上。

安装

Cocoapods

pod 'BottomCard'

Carthage

github "EvgeniyGulkov/BottomCard"

使用

设置

可以将这个视图作为简单的UIView使用Interface Builder进行设计,或者通过编程方式添加。您可以添加任意数量的点。最高点值是bottomCardView的高度限制。

使用示例

import BottomCard

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
}

从顶部使用

alt-text

bottomCardView.side = .top

跟踪高度

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

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

func bottomCardView(viewHeightDidChange height: CGFloat)

跟踪动画

您还可以使用代理方法跟踪动画

func bottomCardView(popAnimationDidStart animation: POPAnimation)

func bottomCardView(popAnimationDidApply animation: POPAnimation)

func bottomCardView(popAnimationDidReach animation: POPAnimation)

func bottomCardView(popAnimationDidStop animation: POPAnimation, finished: Bool)

作者

@EvgeniyGulkov[email protected]

许可

BottomCard 在MIT许可下可用。更多信息请参阅LICENSE文件。