我正在尝试使用Cartography为 UILabel 设置动画 并使用以下代码:
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)
我希望我的 UILabel 在动画的开头和结尾居中。但是,它似乎从超级视图的左上角开始。我在这里做错了什么?