GithubHelp home page GithubHelp logo

jxbottomsheetview's Introduction

JXBottomSheetView

之前写了一个类似的列表滚动视图,地址:https://github.com/pujiaxin33/JXBottomSheetTableView 里面的实现方案还是挺有趣的,对外完全封装了里面的滚动控制细节,且以UITableView的子类实现。无奈越*的操作越容易翻车。里面的应用场景比较狭窄,需求一变动就GG了。 所以重新写了这个库,使用场景更大,使用更方便,交互更友善,好了,不说了,快上车吧!

特性

  • 支持长距离滚动,不断手势:当列表视图滚动到规定的最高点时,停止视图移动,转而滚动里面的内容;
  • 内容自适应:当列表的数据源发生变动时,会根据最新的contentSize调整布局;
  • 切换流畅:最大、最小的手势切换,借鉴了系统UIScrollViewPagingEnabled切换效果;

预览

  • 普通短距离滚动

  • 长距离滚动,手势没有停掉。滚动到顶部的时候,继续滚动里面的内容

  • 内容自适应,根据contentViewcontentSize自动调整布局

属性/方法

属性/方法 描述
defaultMininumDisplayHeight 默认最小内容高度,当contentSize.height更小时,会更新mininumDisplayHeight值。
defaultMaxinumDisplayHeight 默认最大内容高度,当contentSize.height更小时,会更新maxinumDisplayHeight值。
displayState 当前展示状态,最大或最小
triggerDistance 滚动多少距离,可以触发展开和收缩状态切换。
triggerVelocity 触发状态切换的滚动速度,points/second
contentView: UIScrollView 用于承载内容的视图,UITableView、UICollectionView皆可。
displayMax() 显示最大内容
displayMin() 显示最小内容

使用

        tableView = UITableView.init(frame: CGRect.zero, style: .plain)
        
        let bottomSheet = JXBottomSheetView(contentView: tableView)
        bottomSheet.defaultMininumDisplayHeight = 100
        bottomSheet.defaultMaxinumDisplayHeight = 300
        bottomSheet.displayState = .minDisplay
        bottomSheet.frame = self.view.bounds
        view.addSubview(bottomSheet)

注意

  • 内部会影响到外部的代码

    if let tableView = contentView as? UITableView {
              tableView.estimatedRowHeight = 0
          }
    
  • 数据源的增删,请使用reloadData,而不是insertRowsdeleteRows刷新页面。因为...你试一下就知道了。

jxbottomsheetview's People

Contributors

pujiaxin33 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.