-1

Apple photos can change columns with pin zoom smoothly,how it work?

i have coustom UICollectionViewFlowLayout , use UIPinchGestureRecognizer, but not work well


this  is my custom layout 
- (void)prepareLayout {
    [super prepareLayout];
    
    [self.attrList removeAllObjects];
    NSInteger itemCount = [self.collectionView numberOfItemsInSection:0];
    for (int i = 0 ; i < itemCount; i++) {
        NSInteger rowIdx = floor(i * 1.0 / self.columns);
        NSInteger columIdx = i % self.columns;
        NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:0];
        UICollectionViewLayoutAttributes *attribute = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath];
        CGPoint point = CGPointMake((self.itemSize.width + 10) * columIdx, (self.itemSize.height + 10) * rowIdx);
        CGRect rect = CGRectMake(point.x, point.y, self.itemSize.width, self.itemSize.height);
        
        CGRect newRect = CGRectApplyAffineTransform(rect, CGAffineTransformMakeScale(self.scale, self.scale));
        attribute.frame = newRect;
        [self.attrList addObject:attribute];
    }
}

0 Answers0