UICollectionView顶部和侧面的浮动标头 [英] UICollectionView Floating Headers on Top and Side

查看:152
本文介绍了UICollectionView顶部和侧面的浮动标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你如何在uicollectionview中实现标题?我知道你可以添加补充视图,但我不知道如何让它们在像uitableview中的标题那样的部分上面漂浮。

以下是我的情况:我有一个采用网格格式布局的单元格的集合视图。您可以水平和垂直滚动。我想在顶部有一个标题,这样当您水平滚动时,它会与它水平滚动,但不会垂直滚动。我也想要在左边垂直滚动collectionview但不水平的同类事物。正在使用补充视图实现此正确的方法吗?



我正在寻找的最终功能类似于iOS上的Numbers电子表格应用程序。



预先感谢您的帮助!

解决方案

iOS9更新:

  let flow = collectionView.collectionViewLayout as! UICollectionViewFlowLayout 
flow.sectionHeadersPinToVisibleBounds = true

传递它。


How do you implement headers in a uicollectionview? I know you can put in supplementary views, but I don't know how to make them "float" above a section like headers in a uitableview do.

Here's my situation: I have a collectionview with the cells laid out in a grid format. You can scroll horizontally and vertically. I want to have a header on top so that when you scroll horizontally it scrolls horizontally with it, but it doesn't scroll vertically. I also want the same sort of thing on the left side where it scrolls vertically with the collectionview but not horizontally. Is implementing this with supplementary views the right approach?

The final functionality I am looking for is similar to that of the Numbers spreadsheet app on iOS.

Thanks in advance for your help!

解决方案

Update for iOS9:

let flow = collectionView.collectionViewLayout as! UICollectionViewFlowLayout
flow.sectionHeadersPinToVisibleBounds = true

Pass it along.

这篇关于UICollectionView顶部和侧面的浮动标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆