- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我想要达到的效果是一种粘性标题单元格。粘性细胞漂浮在其他细胞之上对我来说很重要。有点像这样:
┌──────────┐
│ │
│ Cell 0 │
│ ├┐
└┬─────────┘│
│ Cell 4 │
│ │
└──────────┘
┌──────────┐
│ │
│ Cell 5 │
│ │
└──────────┘
┌──────────┐
│ │
│ Cell 6 │
│ │
└──────────┘
单元格 4、5 和 6 通常是可见的,我在 layoutAttributesForElementsInRect:
期间在我的 UICollectionViewFlowLayout
子类中构建单元格 0 的属性。我所做的就是调用 super 实现,确定我需要添加到哪个单元格,然后构造 UICollectionViewLayoutAttributes(forCellWithIndexPath:)
。然后,我将它的 zIndex
设置为 1
(默认为 0
)。
我遇到的问题是 UICollectionView
似乎总是忽略 zIndex
┌──────────┐
│ │
│ Cell 0 │
│┌─────────┴┐
└┤ │
│ Cell 4 │
│ │
└──────────┘
┌──────────┐
│ │
│ Cell 5 │
│ │
└──────────┘
┌──────────┐
│ │
│ Cell 6 │
│ │
└──────────┘
现在我相信可以使用 3d 变换从视觉上解决这个问题,但这对我不起作用,因为我不希望任何点击进入顶部的单元格。因此,在此示例中,我不希望 Cell 4 接收用于 Cell 0 的抽头。
有人有什么想法吗?这是在 iOS 8.4 上。
最佳答案
由于 UIKit 错误,更新 UICollectionViewLayoutAttributes.zIndex
不起作用。
这段代码可以解决问题:
// In your UICollectionViewCell subclass:
override func apply(_ layoutAttributes: UICollectionViewLayoutAttributes) {
super.apply(layoutAttributes)
layer.zPosition = CGFloat(layoutAttributes.zIndex) // or any zIndex you want to set
}
关于ios - UICollectionView 不遵守 UICollectionViewLayoutAttributes 的 zIndex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31697578/
我正在尝试构建一个带有分页的 Collection View (将单元格显示为预览)并发现 this教程。我从 Xcode 收到错误,猜测这一定是由于 Xcode 更新所致(因为该教程似乎对很多人都有
我想在不重新加载或更改布局对象的情况下更改一个 UICollectionViewCell 的 UICollectionViewLayoutAttributes 属性 我做了 UICollectionV
我最近开始使用很棒的 UICollectionView API,取得了合理的进展,但几乎一整天都被一个问题困住了,我希望有人能帮助我: 我需要向某些单元格的属性添加一些自定义详细信息。为了做到这一点,
我正在尝试对 UICollectionViewLayoutAttributes 进行子类化,以便我可以添加一个额外的属性 points(CGPoints 数组)。 该子类被设计为仅用作装饰 View
我的 ios 应用程序崩溃,但出现以下异常: void HandleExceptions(NSException *__strong):875 ERROR: uncaught exception: n
我已将 UICollectionViewLayoutAttributes 类子类化并添加了一些自定义属性。 在我的自定义 UICollectionViewLayout 类中,我覆盖了静态+ (Clas
标题是我遇到的错误,我不知道为什么,但这里有一些信息,希望这里有人可以解释我。 我已经对 UICollectionViewFlowLayout 进行了子类化,因为这可以让我在 prepareLayou
我正在阅读一个使用 swift 的开源项目的一些代码。这里我遇到了代码[CGFloat: [UICollectionViewLayoutAttributes]](),我不明白代码的用法,我什至不知道如
我试图了解 UICollectionViewLayout 的工作原理并找到了这个示例代码。 https://developer.apple.com/documentation/uikit/uicoll
我想在 UICollectionViewLayout 中执行转换动画。好吧,这很容易实现,但我找不到设置 UICollectionViewLayoutAttributes 的 anchorPoint
我只是找不到如何在自定义单元格的 apply() 方法中访问自定义布局属性。 我必须为我的 CollectionViewLayoutAtrributes 实现自定义布局属性,因此我将它们子类化。到目前
我对 UICollectionViewFlowLayout 进行了子分类,在该子类中,我正在更改 UICollectionViewLayoutAttributes 框架,以便它们看起来更大或更小 -
我想要达到的效果是一种粘性标题单元格。粘性细胞漂浮在其他细胞之上对我来说很重要。有点像这样: ┌──────────┐ │ │ │ Cell 0 │ │ ├┐
我有两个自定义 UICollectionViewLayout 对象,它们使用自定义 UICollectionViewLayoutAttributes 子类。这些自定义属性添加了一个属性 tintAlp
我已经使用 CustomLayout 在 CollectionView 中完成了一个 View 。在 iOS6 中它运行得很好,但在 iOS7 中它抛出了这样的异常。 由于未捕获的异常“NSInter
声明变量时出现问题。这就是我的情况。 let att = UICollectionViewLayoutAttributes(layoutAttributesForItem(at: in
我有一个 UICollectionViewFlowLayout 的子类,我已经定义了 layoutAttributesForElementsInRect 方法 在里面我试图制作一个 NSMutable
我有一个带有自定义 UICollectionLayout 的 UICollectionView。一切正常,直到我尝试插入一行…… 然后我收到以下错误,似乎无法弄清楚如何解决它。 *** Termina
我正在使用像这样的自定义 UICollectionViewLayout : override func prepareLayout() { cache.removeAll(keepCa
我们有以下代码在 Swift 3 中不再工作,但在以前的 Swift 版本中工作。在代码行 array += [attributes] 中,我们收到错误“Binary Operator '+=' ca
我是一名优秀的程序员,十分优秀!