ios - UICollectionViewCell 上的 CGAffineTransform 没有给出预期的结果

标签 ios objective-c uicollectionview uicollectionviewcell cgaffinetransform

我想让 UICollectionView 中当前选定的单元格“凸起”——它应该比相邻的单元格大。

我试过:

cell.transform = CGAffineTransformMakeScale(1.5, 1.5);

这确实使单元格变大了 - 但它会夹到 UICollectionView 框架并且单元格的重叠不正确 - 单元格将重叠在它左边的单元格顶部 - 但它会在右边的单元格“下方”

我希望它类似于 OSX dock 中的“放大”效果。

如何更改单元格的“Z”并使其不剪裁到 UICollectionView 的边界?

enter image description here

最佳答案

but it clips to the UICollectionView frame

尝试将您的 Collection View 的 clipToBounds 设置为 false。 z-index 仅适用于具有相同父 View 的 View 。

the cell will overlap on top of the cell left to it - but it will be "under" the cell right to it.

zPosition 在这里应该有所帮助。你可以这样设置

cell.layer.zPosition = 1; //standard is 0, don't forget to set it back to zero

如果你使用 xcode < 5 你需要包含 QuartCore

#include <QuartzCore/QuartzCore.h>

关于ios - UICollectionViewCell 上的 CGAffineTransform 没有给出预期的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19900764/

相关文章:

iphone - 音频队列回调函数是否必须是 C 风格的函数?或者它可以是一种客观的 C 风格方法吗?

ios - 如何创建不断增长的 iOS 按钮?

swift - 无法使用全局变量访问 collectionView 单元格变量

ios - Objective C (iOS) 中的 VLA 可变长度数组,会发生什么?

ios - 在 iphone 上替换/加载数据库

ios - 无法在 Swift xcode 6.3.1 中使用类型为 'functionName' 的参数列表调用 '([(nameOfClass)])'

ios - 如何在 iPhone 稍微滚动时停止 CLLocationManager 标题值更改。

objective-c - Swift 框架中的 Google Plus 框架(objc-c) 文件

ios - UICollectionView 自定义 header 不显示 Swift 4

ios - 具有部分和多个项目的 IGListKit