UICollectionViewTransitionLayout – 模仿iOS7照片集合视图布局

前端之家收集整理的这篇文章主要介绍了UICollectionViewTransitionLayout – 模仿iOS7照片集合视图布局前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在 animating changes in a collection view读苹果 guidelines,试图模仿照片应用程序.选择图像时,图像会从其位于集合视图中的区域“增长”到全尺寸视图.

Apple注意到使用UICollectionViewLayout对象但对我来说它看起来非常混乱,并且全尺寸图库中的最终图像不可见,因为动画集中在集合视图上.

我的代码如下

-(void)setHorizontalLayout:(BOOL)layout
{
    if (layout == YES)
    {


        UICollectionViewTransitionLayout *layout =[self.collectionView startInteractiveTransitionToCollectionViewLayout:[self getHorizontalPagingLayout] completion:^(BOOL completed,BOOL finish) {
            [self.collectionView setPagingEnabled:YES];
        }];

        [self.collectionView.collectionViewLayout invalidateLayout];
        layout.transitionProgress = 0.1;
        double delayInSeconds = 0.1;
        dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW,(int64_t)(delayInSeconds * NSEC_PER_SEC));
        dispatch_after(popTime,dispatch_get_main_queue(),^(void){
            [self updateLayout:layout];
            //[self.collectionView.collectionViewLayout invalidateLayout];
            //[self.collectionView finishInteractiveTransition];

        });
        [self.collectionView.collectionViewLayout invalidateLayout];
        return;
}
}

-(void)updateLayout:(UICollectionViewTransitionLayout *)layout
{
    if (layout.transitionProgress >= 1.0)
    {

        [self.collectionView finishInteractiveTransition];
        return;
    }
    double delayInSeconds = 0.05;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW,(int64_t)(delayInSeconds * NSEC_PER_SEC));
    dispatch_after(popTime,^(void){
        layout.transitionProgress += 0.005;
        [self.collectionView.collectionViewLayout invalidateLayout];
        [self updateLayout:layout];
    });

}

解决方法

如何使用自定义转换呈现带有UIImageView的UIViewController?本教程帮助了我.

http://www.teehanlax.com/blog/custom-uiviewcontroller-transitions/

猜你在找的iOS相关文章