从下到上滚动



有没有办法在集合视图中自下而上滚动,所以基本上第一个单元格将位于屏幕底部,您可以向上滚动以查看其余单元格

要从 UICollection 视图的末尾开始,只需使用:

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)
    self.collectionView!.scrollToItemAtIndexPath(indexForTheLast, atScrollPosition: UICollectionViewScrollPosition.Bottom, animated: false)
}

yourCollectionView.contentOffset = CGPointMake(0, yourCollectionView.contentSize.height - yourCollectionView.bounds.size.height);

但请记住,仅当您的内容大小.高度>边界.大小.高度时,才这样做。

苹果文档

最新更新