func cubeTransition(label label:UILabel, text: String, direction:AnimationDirection) {
//1
let auxLabel = UILabel(frame: label.frame)
auxLabel.text = text
auxLabel.font = label.font
auxLabel.textAlignment = label.textAlignment
auxLabel.textColor = label.textColor
auxLabel.backgroundColor = label.backgroundColor
//2
let auxLabelOffset = CGFloat(direction.rawValue) * label.frame.size.height/2.0
auxLabel.transform = CGAffineTransform(scaleX: 1.0, y: 0.1).concatenating( CGAffineTransform(translationX: 0.0, y: auxLabelOffset))
label.superview!.addSubview(auxLabel)
//3
UIView.animate(withDuration: 0.5, delay: 0.0, options: .curveEaseOut, animations: {
auxLabel.transform = .identity
label.transform = CGAffineTransform(scaleX: 1.0, y: 0.1).concatenating( CGAffineTransform(translationX: 0.0, y: -auxLabelOffset))
}, completion: {_ in
label.text = auxLabel.text
label.transform = .identity
auxLabel.removeFromSuperview()
})
}
此示例中有一行代码,即“auxLabel.transform = .identity”这是什么意思?我很困惑,提前谢谢。