Make UICollectionView zoomable?

2019-01-11 04:58发布

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

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

1条回答
贼婆χ
2楼-- · 2019-01-11 05:33

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).

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.

查看更多
登录 后发表回答