Swift animation with constraint
13,495
Yes this is possible. You can do something like this:
func AnimateHeight() {
UIView.animateWithDuration(1.5, animations: {
self.heightCons.constant = 250 // Some value
self.view.layoutIfNeeded()
})
}
Where self.heightCons
is an IBOutlet
to the height constraint on the UIView
.
If you don't use storyboards you can check out how to create layout constraints programmatically.
For info on Core Animation and Auto layout: Combining autolayout with core animation
Author by
ramsserio
Updated on June 19, 2022Comments
-
ramsserio almost 2 years
Is it possible to make a UIView animation by changing constraints?
Basically, I want to animate
myv
(UIView) which has x, y, height and width constraints, using:UIView.animateWithDuration(1.5) {}
by changing the old constraints.