通过捏手势缩放UICollectionView

时间:2017-08-29 16:27:53

标签: ios objective-c uicollectionview cgaffinetransform cgaffinetransformscale

我有UICollectionView里面有很多细胞(约5k +)。我想捏缩放/缩小。我在每次捏合时都试过invalidateLayout。它真的很慢。所以我想使用CGAffineTransformMakeScale,但我不知道如何在此之后滚动。 我的代码是:

- (void)didReceivePinchGesture:(UIPinchGestureRecognizer *)gesture {
static CGFloat scaleStart;

if (gesture.state == UIGestureRecognizerStateBegan) {
    scaleStart = self.venueLayoutZoom;
}
else if (gesture.state == UIGestureRecognizerStateChanged) {
    CGAffineTransform transform = CGAffineTransformMakeScale(self.venueLayoutZoom, self.venueLayoutZoom);
    self.activeCollectionNode.view.transform = transform;
    self.activeCollectionNode.view.contentSize = CGSizeMake(318 * self.venueLayoutZoom, 500 * self.venueLayoutZoom);
}
}

但是当放大时,我无法左右滚动。帮助我。

1 个答案:

答案 0 :(得分:0)

使用

modelIsValid