• SnapKit 动画


    1. 控制器中viewDidLoad使用 要在主线程

            ///更新动画
            DispatchQueue.main.async {
                UIView.animate(withDuration: 0.5) {[weak self] in
                    self?.centerIV.snp.updateConstraints { (make) in
                        make.top.equalTo(TGSNavBarHeight + 5)
                        make.width.equalTo(TGSScaleWidth(value: 202))
                        make.height.equalTo(TGSScaleWidth(value: 25))
                    }
                    
                    self?.loginView.snp.updateConstraints({ (make) in
                        make.top.equalTo(loginViewY)
                    })
                   ///核心代码
                    self?.view.layoutIfNeeded()
                }
            }
    

      

    2. 其他地方 不需要主线程也能实现自定义点击事件, 自定义view

        /// 点击事件
        private func clickEvent(){
            loginView.clickHandle = {[weak self] (clickType) in
                switch clickType {
                case .close:
                    if let strongSelf = self{
                        UIView.animate(withDuration: 0.5) {
                            strongSelf.centerIV.snp.updateConstraints { (make) in
                                make.top.equalToSuperview().offset(TGSScreenHeight*0.5)
                                make.width.equalTo(TGSScaleWidth(value: 270))
                                make.height.equalTo(TGSScaleWidth(value: 33))
                            }
                            strongSelf.loginView.snp.updateConstraints { (make) in
                                make.top.equalTo(TGSScreenHeight)
                            }
                            strongSelf.view.layoutIfNeeded()
                        } completion: { (_) in
                            strongSelf.navigationController?.popViewController(animated: true)
                        }
                    }
                case .clickCodeBtn(let phoneNum):
                    TGSLOG(message: "phoneNum = (phoneNum)")
                    ///开始请求 -》 请求成功 启动定时器/弹框
                    self?.loginView.startCountdown()
                    
                default:break
                }
            }
        }
    

      

  • 相关阅读:
    python kivy 简单入门
    django 入门实例
    window docker安装
    apache进程和用户请求的关系
    php cookie工作原理
    react-router 简单的nginx配置
    node单线程支撑高并发原理(node异步I/O)
    知识图谱
    java
    java
  • 原文地址:https://www.cnblogs.com/qingzZ/p/14005859.html
Copyright © 2020-2023  润新知