使 UICollectionView 可缩放? [英] Make UICollectionView zoomable?
问题描述
有没有什么方法可以让UICollectionView
zoomable
,即当你捏的时候,所有的单元格都可以放大缩小.
我可以通过从 delegate
方法返回 UIScrollView
的唯一 subview
在 UIScrollView
中实现这一点
Is there any method make the UICollectionView
zoomable
, i.e. when you pinch, all the cells can be zoomed in and out.
I can implement this in UIScrollView
by returning the only subview
of the UIScrollView
from delegate
method
- (UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView
由于 UICollectionView
是一种 UIScrollView
,有没有办法或解决方法来实现它?UICollectionView
是否有一个包含所有单元格的直接子视图?
谢谢
Since UICollectionView
is kind of UIScrollView
, is there a way or work around to implement this? Does the UICollectionView
has one direct subview that contains all cells?
Thanks
推荐答案
我认为您要求的内容类似于 WWDC1012
视频中的内容,标题为 高级集合视图和构建自定义布局(演示从 20:20 开始).
I think what you're asking for looks like what is done in the WWDC1012
video entitled Advanced Collection Views and Building Custom Layouts (demo starts at 20:20).
您基本上必须将 pinchGesture
添加到您 UICollectionView
,然后将 pinch 属性
(scale, center) 传递给 UICollectionViewLayout
(它是 UICollectionViewFlowLayout
的 subclass
),然后您的布局将执行 zoom
transformations> 在所需的单元格上.
You basically have to add pinchGesture
to you UICollectionView
, then pass the pinch properties
(scale, center) to the UICollectionViewLayout
(which is a subclass
of UICollectionViewFlowLayout
), your layout will then perform the transformations
needed to zoom
on the desired cell.
这篇关于使 UICollectionView 可缩放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!