I'm trying to animate a UILabel using Cartography and using this code:
let group = ConstraintGroup()
constrain(alertLabel, replace: group) { alertLabel in
alertLabel.centerX == alertLabel.superview!.centerX
alertLabel.width == alertLabel.superview!.width * Constants.alertLabelWidthMultiplier
alertLabel.bottom == alertLabel.superview!.top + 0
}
constrain(alertLabel, replace: group) { alertLabel in
alertLabel.centerX == alertLabel.superview!.centerX
alertLabel.width == alertLabel.superview!.width * Constants.alertLabelWidthMultiplier
alertLabel.bottom == alertLabel.superview!.top + 60
}
UIView.animateWithDuration(0.5, animations: alertLabel.layoutIfNeeded)
I want my UILabel to be centered in the beginning and end of the animation. However, it seems to start on the top left corner of the superview instead. What am I doing wrong here?