zoukankan      html  css  js  c++  java
  • 不用抽屉实现qq左侧拦展示功能(简单界面实现)

    重点逻辑在于,实现动画过程给最上层的控制器添加一个view,来实现动画的返回功能。

    class first: UIViewController {

        //动画按钮

        var aniBtn:UIButton?

        //三个测试控制器

        var three: Three?

        var four: Three?

        var two: Two?

        //覆盖的view

        private var rightCoverView: UIView!

        //动画参数

        var leftShowTransform: CGAffineTransform {

            get {

                return CGAffineTransformScale(CGAffineTransformMakeTranslation(SlideMaxOffset * 0.8, SlideMaxOffset * 0.8 * 0.2 ), 0.8, 0.8)

            }

        }

     

        var leftHideTransform: CGAffineTransform {

            get {

                return CGAffineTransformScale(CGAffineTransformMakeTranslation(SlideMinOffset * 0.8, 0), 1.00, 1.00)

            }

        }

     

        var SlideMaxOffset: CGFloat {

            get {

                return UIScreen.mainScreen().bounds.size.width * 0.7

            }

        }

     

        var SlideMinOffset: CGFloat {

            get {

                return UIScreen.mainScreen().bounds.size.width * 0.0

            }

        }

        

        

        override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {

            print("touch")

        }

        

        override func viewDidLoad() {

            super.viewDidLoad()

            self.view.backgroundColor = UIColor.blueColor()

            self.setupSubview()

        }

        

        func setupSubview() {

            two = Two()

            self.view.addSubview(two!.view)

            self.addChildViewController(two!)

            three = {

                let th = Three()

                return th

                }()

            self.view.addSubview(three!.view)

            self.addChildViewController(three!)

            //核心,实现动画的过程给最上面的控制器添加一个view,来实现动画的返回功能

            rightCoverView = {

                let view = UIButton(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.size.width, UIScreen.mainScreen().bounds.size.height))

                let gesture = UITapGestureRecognizer(target: self, action: "hideLeft")

                view.userInteractionEnabled = true

                view.addGestureRecognizer(gesture)

                view.backgroundColor = UIColor.greenColor()

                return view

                } ()

            

            aniBtn = UIButton()

            self.view.addSubview(aniBtn!)

            aniBtn?.frame = CGRectMake(100, 100, 20, 20)

            aniBtn?.backgroundColor = UIColor.redColor()

            aniBtn?.userInteractionEnabled = true

            aniBtn?.addTarget(self, action: "aniBtnClick", forControlEvents: .TouchDown)

        }

        func aniBtnClick (){

            three!.view.addSubview(rightCoverView)

            UIView.animateWithDuration(0.45, delay: 0, usingSpringWithDamping: 1.0, initialSpringVelocity: 0.45, options: .BeginFromCurrentState, animations: { () -> Void in

                self.three?.view.transform = self.leftShowTransform

                

                }) { (complete) -> Void in

                    print("回调成功")

            }

        }

        func hideLeft() {

            rightCoverView.removeFromSuperview()

            UIView.animateWithDuration(0.45, delay: 0, usingSpringWithDamping: 1.0, initialSpringVelocity: 0.45, options: .BeginFromCurrentState, animations: { () -> Void in

                self.three?.view.transform = self.leftHideTransform

                

                }) { (complete) -> Void in

                    print("yes")

            }        

        }

    }

  • 相关阅读:
    css 和 svg 实现蚂蚁行军效果
    ASP.NET Core使用Swagger实现接口文档并分组
    Centos7+DockerCompose部署ASP.NET Core3.1应用
    Centos7+Docker部署ASP.NET Core3.1应用
    ASP.NET Core下的Cache
    在asp.net web form项目中添加webapi接口
    windows服务中对外提供API接口
    ASP.NET Core使用log4net记录日志
    SSL踩坑ERR_SSL_VERSION_OR_CIPHER_MISMATCH
    C# 调用微信接口上传素材和发送图文消息
  • 原文地址:https://www.cnblogs.com/hazhede/p/5462614.html
Copyright © 2011-2022 走看看