Reputation: 10744
I would like to convert this View
based animation below into Layer
based.
@IBOutlet weak var constraintTopContainerHeight: NSLayoutConstraint!
override func viewDidLoad() {
super.viewDidLoad()
var value:CGFloat
switch (someTag)
{
case 1:
value = CGFloat(self.view.bounds.height / 3)
case 2:
value = CGFloat(self.view.bounds.height / 2)
case 3:
value = CGFloat(self.view.bounds.height * 0.8)
default:
value = 0.0
}
UIView.animateWithDuration(1.5, delay: 0.0,
usingSpringWithDamping: 0.3, initialSpringVelocity: 0.0,
options: nil, animations: {
self.constraintTopContainerHeight.constant = value
self.view.layoutIfNeeded()
}, completion: nil)
}
}
How do I get a Constraint
to use Layer
based animation instead of the current View
based animation. Code please.
Upvotes: 0
Views: 26
Reputation: 2879
First of all, you should set your constraint outside of your UIView animation.
Also, you can't animate constraints with Core Animation.
The auto-layout guide from Apple explains.
Upvotes: 1