简体   繁体   English

如何从收藏夹视图单元中对图像进行动画处理,以通过单击将其移动到全屏

[英]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.

相关问题 如何通过快速点击集合视图的单元格在表视图中重新加载数据 - How to reload data in table view by tapping the cell of collection view in swift 在 iPad 上的上下文菜单中点击预览不会对全屏视图控制器的演示进行动画处理 - Tapping preview in context menu on iPad doesn't animate presentation of full screen view controller 轻按时,iOS Animate表格视图单元会变为全屏 - iOS Animate table view cell into full screen when tapped 点击集合视图单元格以向 map 添加注释 - Tapping a collection view cell to add annotations to a map 如何在集合视图单元格中更改图像视图 - How to change Image view in collection view cell Swift Animate Background无法从集合视图单元中工作 - Swift Animate Background not working from a collection view cell 如何将图像从ios中的本地库添加到集合视图单元格中? - How to add image into collection view cell from local library in ios? 如何将图像从保存的相册添加到收藏夹视图单元格中? - How to add image into collection view cell from saved photo albums? 如何为集合视图单元格扩展动画以显示数据标签 - how to animate collection view cell expansion to display data labels 从滚动视图全屏显示图像 - Image in full screen from scroll view
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM