swift UICollectionView + RxReachedBottom.swift
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift UICollectionView + RxReachedBottom.swift相关的知识,希望对你有一定的参考价值。
extension UICollectionView {
public var rx_reachedBottom: Observable<Void> {
return self.rx.contentOffset
.map { contentOffset in
var responder: UIResponder = self
var viewController: UIViewController? = nil
while let next = responder.next {
viewController = next as? UIViewController
if viewController != nil {
break
}
responder = next
}
let statusBarHeight = UIApplication.shared.statusBarFrame.height
let navigationBarHeight = viewController?.navigationController?.navigationBar.bounds.height ?? 0
let tabBarHeight = viewController?.tabBarController?.tabBar.bounds.height ?? 0
let bottomOffset = contentOffset.y + self.contentInset.top + self.bounds.height
- statusBarHeight - navigationBarHeight - tabBarHeight
return bottomOffset >= self.contentSize.height - self.bounds.height / 2
}
.distinctUntilChanged()
.filter { $0 }
.map { _ in Void() }
}
}
以上是关于swift UICollectionView + RxReachedBottom.swift的主要内容,如果未能解决你的问题,请参考以下文章
Swift:滚动时 UICollectionView 标题消失
swift UICollectionView + RxReachedBottom.swift
如何将 UIPageControl 连接到 UICollectionView (Swift)
Swift 4 UICollectionView 检测滚动结束
如何使用 swift 重置 UICollectionView 滚动位置?
Swift 3 - 带有填充的 UICollectionView 中心单元