Как увеличить содержимое ячейки в uicollectionview

введите описание изображения здесь

На изображении выше,A,B,C,D,E - каждая пользовательская ячейка в виде коллекции, и я хочу увеличить ячейку одну за другой, как ячейка c.

Любое предложение?

2 ответа

Решение

Просто вызовите этот метод, когда ваша ячейка viewview щелкнет

[self animateZoomforCell:cell]; // pass cell as collectionviewcell

-(void)animateZoomforCell:(UICollectionViewCell*)zoomCell
{
    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{

        zoomCell.transform = CGAffineTransformMakeScale(1.6,1.6);
    } completion:^(BOOL finished){
    }];
}
-(void)animateZoomforCellremove:(UICollectionViewCell*)zoomCell
{
    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{

        zoomCell.transform = CGAffineTransformMakeScale(1.0,1.0);
    } completion:^(BOOL finished){
    }];
}

В Swift 3 на основе решения Himanshu Moradiya:

 func animateZoomforCell(zoomCell : UICollectionViewCell)
{
    UIView.animate(
        withDuration: 0.2,
        delay: 0,
        options: UIViewAnimationOptions.curveEaseOut,
        animations: {
                        zoomCell.transform = CGAffineTransform.init(scaleX: 1.2, y: 1.2)
            },
    completion: nil)
}
func animateZoomforCellremove(zoomCell : UICollectionViewCell)
{
    UIView.animate(
        withDuration: 0.2,
        delay: 0,
        options: UIViewAnimationOptions.curveEaseOut,
        animations: {
            zoomCell.transform = CGAffineTransform.init(scaleX: 1.0, y: 1.0)
    },
        completion: nil)

}
Другие вопросы по тегам