IOS 自定义转场动画

 1,firstVCView 为你当前view 2,secondVCView 为你需要跳转到的view 3,viewCon 同第二项不要传入view直接传入对象即可。

 *这里是调用   UIViewObject  为你要跳转的类  id是你需要传递的值

  let view = UIViewObject()
  view.id = self.id

  self.performAnimationBack(self.view, secondVCView: lineList.view, viewCon: lineList)

 

    // 自定义过场动画
    func performAnimationBack(firstVCView: UIView, secondVCView: UIView, viewCon: UIViewController) {
        // Assign the source and destination views to local variables.
        
        // Get the screen width and height.
        let screenWidth = UIScreen.mainScreen().bounds.size.width
        let screenHeight = UIScreen.mainScreen().bounds.size.height
        
        // Specify the initial position of the destination view.
        secondVCView.frame = CGRectMake(-screenWidth, 0.0, screenWidth, screenHeight)
        
        // Access the app's key window and insert the destination view above the current (source) one.
        let window = UIApplication.sharedApplication().keyWindow
        window?.insertSubview(secondVCView, aboveSubview: firstVCView)
        
        // Animate the transition.
        UIView.animateWithDuration(0.4, animations: { () -> Void in
            firstVCView.frame = CGRectOffset(firstVCView.frame, screenWidth, 0.0)
            secondVCView.frame = CGRectOffset(secondVCView.frame, screenWidth, 0.0)
            }) { (Finished) -> Void in
//                self.dismissViewControllerAnimated(true, completion: nil)
                self.presentViewController(viewCon,
                    animated: false,
                    completion: nil)
        } 
    }

 

 

转载于:https://www.cnblogs.com/andicu/p/4940111.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值