登录 立即注册
金钱:

Code4App-iOS开发-iOS 开源代码库-iOS代码实例搜索-iOS特效示例-iOS代码例子下载-Code4App.com

模仿格瓦拉电影的转场特效

[复制链接]
来自: yfnz0549 分类: iOS精品源码 上传时间: 2016-5-15 16:59:57
Tag:视图切换 动画 格瓦拉 切换 转场

项目介绍:



主要实现代码:

[Objective-C] 查看源文件 复制代码
- (CGFloat)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext{
    return _duration;
}


- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext{
    if (self.type == animate_push) {
        [self pushAnimateWithanimateTransition:transitionContext];
    }else{
        [self popAnimateWithanimateTransition:transitionContext];
    }
}

- (void)pushAnimateWithanimateTransition:(id<UIViewControllerContextTransitioning>)transitionContext{


    UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
    UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];

    //起始位置
    CGRect originFrame = [fromVC.sf_targetView convertRect:fromVC.sf_targetView.bounds toView:fromVC.view];
    //动画移动的视图镜像
    UIView *customView = [self customSnapshoFromView:fromVC.sf_targetView];
    customView.frame = originFrame;

    //移动的目标位置
    CGRect finishFrame = [toVC.sf_targetView convertRect:toVC.sf_targetView.bounds toView:toVC.view];

    UIView *containView = [transitionContext containerView];

    //背景视图 灰色高度
    CGFloat height = CGRectGetMidY(finishFrame);
    toVC.sf_targetHeight = height;

    //背景视图 灰色
    UIView *backgray = [[UIView alloc] initWithFrame:CGRectMake(0, 0, k_SF_SCREEN_WIDTH, k_SF_SCREEN_HIGHT)];
    backgray.backgroundColor = [UIColor lightGrayColor];
    //背景视图  白色
    UIView *backwhite = [[UIView alloc] initWithFrame:CGRectMake(0, height, k_SF_SCREEN_HIGHT, k_SF_SCREEN_HIGHT-height)];
    backwhite.backgroundColor = [UIColor whiteColor];


    toVC.view.frame = [transitionContext finalFrameForViewController:toVC];
    [containView addSubview:toVC.view];
    [containView addSubview:backgray];
    [backgray addSubview:backwhite];
    [containView addSubview:customView];

    //动画
    [UIView animateWithDuration:_duration/3 animations:^{
        customView.frame = finishFrame;
        customView.transform = CGAffineTransformMakeScale(1.1, 1.1);
    } completion:^(BOOL finished) {
        if (finished) {

            [UIView animateWithDuration:_duration/3 animations:^{

                customView.transform = CGAffineTransformIdentity;

            } completion:^(BOOL finished) {
                if (finished) {
                    [UIView animateWithDuration:_duration/3 animations:^{
                        customView.alpha = 0.0;
                    } completion:^(BOOL finished) {
                        if (finished) {
                            [backgray removeFromSuperview];
                            [customView removeFromSuperview];
                            [transitionContext completeTransition:YES];
                        }
                    }];

                    [self addPathAnimateWithView:backgray fromPoint:customView.center];

                }
            }];



        }
    }];
}

DEMO下载:
运行demo可以查看效果,而且在demo中,针对各种文本和图文的实现都有详细的用例


相关源码推荐:

我来说两句
*滑动验证:
所有评论(192)
wtf1024 2016-5-16 15:03:12
虽不明,但觉厉!
回复
wtf1024 2016-5-16 15:03:29
感谢分享,Code4App有你更精彩
回复
yfnz0549 2016-5-16 17:03:49
我只是路过打酱油的。
回复
ogqs0493 2016-5-16 17:29:13
强烈支持楼主ing……
回复
末日孤舰 2016-5-16 21:00:27
感谢分享,Code4App有你更精彩
回复
bensco 2016-5-16 22:18:08
楼主用心了,内容非常精彩。
回复
哈哈就是我 2016-5-17 08:05:57
谢谢分享,下下来看看
回复
哈哈就是我 2016-5-17 08:06:16
强烈支持楼主ing……
回复
xtuphe 2016-5-17 09:07:26
正需要啊,感谢楼主无私分享!
回复
提取码:  下载次数:133 状态:已购或VIP 售价:0(原价:10)金钱 下载权限:初级码农 
3043 1 133
联系我们
首页/微信公众账号投稿

帖子代码编辑/版权问题

QQ:435399051,742864542

如何获得代码达人称号?

代码贡献英雄榜
用户名 下载数
通过邮件订阅最新 Code4App 信息
上一条 /4 下一条
联系我们
关闭
合作电话:
13802416937
Email:
435399051@qq.com
商务市场合作/投稿
问题反馈及帮助
联系我们

广告投放| Github|申请友链|手机版|Code4App ( 粤ICP备15117877号-1 )

快速回复 返回顶部 返回列表