[英]How to animate a image from a collection view cell to move to full screen by tapping on it
I have a horizontal scroll single section collection view of images 我有图像的水平滚动单节集合视图
When you tap on first image in the collectionview
, the image should "grow" with a smooth transition to take up the full screen while the screen behind fades to full black. 当您在
collectionview
点击第一张图像时,图像应以平滑过渡“增长”以占据全屏,而后面的屏幕则逐渐变为全黑。 Tapping the image or the "x" in the top right corner fades this screen out and returns you to your previous screen. 轻触图像或右上角的“ x”将淡出该屏幕,并使您返回上一屏幕。
I can get the image from this method 我可以从这种方法获得图像
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
How can this kind of animation be achieved? 如何实现这种动画?
Following is the sample image, 以下是示例图片,
Try the following code: 尝试以下代码:
[UIView animateWithDuration:1 animations:^{
//if u want to move it to center before you make it big use all code
imgView.center = self.view.center;
} completion:^(BOOL finished) {
[UIView animateWithDuration:1 animations:^{
//just use this if you want it to move to full screen
imgView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
}];
}];
Hope this helps ! 希望这可以帮助 !
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.