iOS应用中使用Auto Layout实现自定义cell及拖动回弹

2020-01-14 20:12:15于丽

    }
    
    func pan() {
        if panGesture.state == UIGestureRecognizerState.Ended {
            UIView.animateWithDuration(0.4, delay: 0, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
                self.middleView.frame.origin.y = self.middleViewOriginY
                }, completion: { (success) -> Void in
                    if success {
                        self.middleViewTopSpaceLayout.constant = self.middleViewTopSpaceLayoutConstant
                    }
            })
            return
        }
        let y = panGesture.translationInView(self.view).y
        middleViewTopSpaceLayout.constant = middleViewTopSpaceLayoutConstant + y
    }

}


查看效果

 

iOS应用中使用Auto Layout实现自定义cell及拖动回弹

22 行代码,拖动回弹效果完成!



注:相关教程知识阅读请移步到IOS开发频道。