swift 分页菜单_具有水平分页的iOS Swift UICollectionView

这篇博客介绍了如何在iOS应用中使用Swift语言创建一个带有水平分页功能的UICollectionView菜单,提供了详细的实现过程。
摘要由CSDN通过智能技术生成

swift 分页菜单

Hey, today I’m presenting you horizontal pagination in swift 5. The reference I have taken from one of my organisation’s library.

嘿,今天我将向您介绍水平5分页。这是我所在组织的一个图书馆提供的参考资料。

If you are new bee then please refer to following links first

如果您是新蜜蜂,请先参考以下链接

  1. https://developer.apple.com/documentation/uikit/uicollectionview

    https://developer.apple.com/documentation/uikit/uicollectionview

  2. https://www.raywenderlich.com/9334-uicollectionview-tutorial-getting-started

    https://www.raywenderlich.com/9334-uicollectionview-tutorial-getting-started

水平分页 (Horizontal Pagination)

Basic pagination works as you pulled to a threshold value. Beyond that, it will hit API and gives some array items back, that you will append to the main array. Pagination consist of 2 things refresh all and load more. Refresh all works when you need fresh content from the beginning and load more works when you need more data at the end. In context with horizontal pagination you will drag collection towards the right to refresh all and in case of load more, you will scroll to last content and drag towards left.

基本分页在您达到阈值时起作用。 除此之外,它将击中API并返回一些数组项,您将这些数组项追加到主数组中。 分页由两件事组成,它们全部刷新加载更多内容 。 当您从一开始就需要新鲜的内容时刷新所有作品,而当您结束时需要更多数据时加载更多作品。 在水平分页的情况下,您将向右拖动集合以刷新所有内容,如果加载更多,则将滚动到最后一个内容并向左拖动。

So moving ahead and let’s create a new project name HorizontalPaginationDemo.

接下来,让我们创建一个新的项目名称Horizo​​ntalPaginationDemo。

项目设置 (Project Setup)

  1. Open default Main.Storyboard, there is default view controller in Interface Builder (IB), add UICollectionView with top, left, right and height to 0,0,0 and 200 respectively.

    打开默认的Main.Storyboard,在Interface Builder(IB)中有默认的视图控制器,将UICollectionView的top,left,right和height分别添加到0、0、0和200。

  2. There is a default UICollectionViewCell present in the collection view. Extend it and add UILabel in the centre.

    集合视图中存在默认的UICollectionViewCell 。 扩展它并在中心添加UILabel

  3. Create an IBOutlet

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值