Snapkit的autolayout约束如何完成动画

参考:http://samisuteria.com/2016/02/16/snapkit-animations/

self.leadingConstraint.updateOffset(0)

view.setNeedsLayout()

UIView.animateWithDuration(0.2, delay: 0, options: [], animations: { () -> Void in 
	self.view.layoutIfNeeded()
})
var leadingConstraint = Constraint()

view.addSubview(someView)
someView.snp_makeConstraints { (make) -> Void in 
	make.width.equalTo(view)
	make.height.equalTo(50)
	leadingConstraint = make.leading.equalTo(view).offset(view.frame.width).constraint
}

view.layoutIfNeeded()

leadingConstraint.updateOffset(0)

UIView.animateWithDuration(0.2, delay: 0, options: [], animations: { () -> Void in 
	self.view.layoutIfNeeded()
})

 

Leave a Reply

Your email address will not be published. Required fields are marked *