zoukankan      html  css  js  c++  java
  • 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
                }
            }
        }
    

      

  • 相关阅读:
    机器学习之线性回归
    Anaconda使用
    Pycharm使用总结
    Mysql使用小tips
    技术转型与考研总结
    C语言的学习
    python 使用小结
    RedHat Linux 忘记密码
    设计模式之单例模式
    Java 读写Properties配置文件
  • 原文地址:https://www.cnblogs.com/qingzZ/p/14005859.html
Copyright © 2011-2022 走看看