【发布时间】:2016-03-26 08:12:48
【问题描述】:
我试图用我的收藏视图选择创建一个很酷的动画。基本上我有一个显示照片单元的集合视图。我想要发生的是让单元格弹出其位置,缩放并移动到屏幕中心,提示用户确认选择。
到目前为止,这是我的代码,但目前动画采用单元格原始帧位置,所以如果我滚动它并没有考虑到帧位置不再相同。
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
PhotoCell *cell = (PhotoCell *)[collectionView cellForItemAtIndexPath:indexPath];
collectionView.allowsSelection = NO;
[self createAnimationWithCell:cell];
}
- (void)createAnimationWithCell:(PhotoCell *)cell {
UIImageView *selectedImage = [[UIImageView alloc] initWithFrame:cell.bounds];
selectedImage.center = cell.center;
selectedImage.image = cell.imageView.image;
[self.view addSubview:selectedImage];
[UIView animateWithDuration:2.5 animations:^{
selectedImage.center = self.view.center;
} completion:^(BOOL finished) {
[selectedImage removeFromSuperview];
self.collectionView.allowsSelection = YES;
}];
}
【问题讨论】:
标签: ios objective-c iphone