我想复制完全相同的didSelect动画/赛格当你点击iPhone的照片应用程序(或在几乎所有其他应用程序中)的照片照片放大的细胞本身变成一个模态视图控制器,并在被解散时最小化到网格所属的任何位置。UICollectionView挖掘动画像iPhone的照片应用程序
我试过Google搜索,但找不到任何关于此的文章。
我想复制完全相同的didSelect动画/赛格当你点击iPhone的照片应用程序(或在几乎所有其他应用程序中)的照片照片放大的细胞本身变成一个模态视图控制器,并在被解散时最小化到网格所属的任何位置。UICollectionView挖掘动画像iPhone的照片应用程序
我试过Google搜索,但找不到任何关于此的文章。
在git上有很多公开回购可能可以做你想做的。有些东西,我发现:
https://github.com/mariohahn/MHVideoPhotoGallery
https://github.com/mwaterfall/MWPhotoBrowser
那些可能过于复杂。另一种选择是在与单元格相同的位置创建UIImageView,然后将其动画化以填充屏幕。这段代码假设collectionView在(0,0)处有一个原点,如果不是,那么在计算初始帧时只需添加collectionView的偏移量。
collectionView.scrollEnabled = false; // disable scrolling so view won't move
CGPoint innerOffset = collectionView.contentOffset; // offset of content view due to scrolling
UICollectionViewLayoutAttributes *attributes = [collectionView layoutAttributesForItemAtIndexPath:[NSIndexPath indexPathForItem:index inSection:0] ];
CGRect cellRect = attributes.frame; // frame of cell in contentView
UIImageView *v = [[UIImageView alloc] initWithFrame:CGRectMake(cellRect.origin.x - innerOffset.x, cellRect.origin.y - innerOffset.y, cellRect.size.width, cellRect.size.height)];
[self.view addSubview:v]; // or add to whatever view you want
v.image = image; // set your image
v.contentMode = UIViewContentModeScaleAspectFit; // don't get stupid scaling
// animate
[UIView animateWithDuration:0.5 animations:^{
[v setFrame:[[UIScreen mainScreen] bounds]]; // assume filling the whole screen
}];
这不是很好的弹出动画,但它应该仍然看起来不错。
你的意思是' cellRect.origin.x - innerOffset.x'而不是'cellRect.origin.x + innerOffset.x'? (与y相同)。 –
@PavloRazumovkyi感谢您指出,固定 – Bourne
[这可能会帮助你](https://github.com/mariohahn/MHVideoPhotoGallery)。它有很多功能的例子。为了使这项工作,你需要使用过渡和动画类。 – Dima
[This](http://stackoverflow.com/questions/12481004/how-to-animate-a-uiimageview-to-display-fullscreen-by-tapping-on-it)可能会回答你的问题 –