【问题标题】:How to animate a image from a collection view cell to move to full screen by tapping on it如何通过点击将集合视图单元格中的图像设置为动画以移动到全屏
【发布时间】:2014-01-23 22:35:43
【问题描述】:
我有一个图像的水平滚动单节集合视图
当您点击collectionview 中的第一张图片时,图片应该会“增长”并平滑过渡以占据全屏,而后面的屏幕会逐渐变为全黑。点击图片或右上角的“x”会淡出此屏幕并返回到上一个屏幕。
我可以通过这个方法得到图像
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
这种动画是怎么实现的?
下面是示例图片,
【问题讨论】:
标签:
ios
objective-c
uiimageview
uicollectionview
fullscreen
【解决方案1】:
试试下面的代码:
[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);
}];
}];
希望这会有所帮助!