Reputation: 81
In the above image,A,B,C,D,E are each custom cell,of collection view and i want to zoom in the cell one by one like c cell.
Any suggestion?
Upvotes: 5
Views: 3165
Reputation: 11
In swift 3 based on Himanshu Moradiya solution:
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)
}
Upvotes: 1
Reputation: 4815
Just call this method when your collectionviewcell click
[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){
}];
}
Upvotes: 2