我的stackview包含2个标签。我想给隐藏过程设置动画,例如当其中一个标签被隐藏时给它淡入淡出动画,或者当其中一个标签被隐藏时给它淡入淡出动画。我该怎么办?
答案 0 :(得分:1)
您应为alpha
中的label
设置动画。
UIView.animate(withDuration: 1, animations: {
disclaimerLabel.alpha = 0
}
答案 1 :(得分:0)
let flash = CABasicAnimation(keyPath: "opacity")
flash.duration = 0.5
flash.fromValue = 1
flash.toValue = 0.1
flash.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
flash.autoreverses = true
flash.repeatCount = 3
la1.layer.add(flash, forKey: nil)