UIView appereance from bottom to top and vice versa(Core Animation)

前端 未结 4 1254
予麋鹿
予麋鹿 2021-02-02 12:24

My goal is to understand and implement feature via Core Animation.
I think it\'s not so hard,but unfortunately i don\'t know swift/Obj C and it\'s hard to understand native

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-02 13:08

    You can use like this Extension

    extension UIView{
        func animShow(){
            UIView.animate(withDuration: 2, delay: 0, options: [.curveEaseIn],
                           animations: {
                            self.center.y -= self.bounds.height
                            self.layoutIfNeeded()
            }, completion: nil)
            self.isHidden = false
        }
        func animHide(){
            UIView.animate(withDuration: 2, delay: 0, options: [.curveLinear],
                           animations: {
                            self.center.y += self.bounds.height
                            self.layoutIfNeeded()
    
            },  completion: {(_ completed: Bool) -> Void in
            self.isHidden = true
                })
        }
    }
    

提交回复
热议问题