[ad_1]
When engaged on this query, I discover that perhaps fade of CATransitionType in CATransition not working or damaged. The remainder of CATransitionType: moveIn, push, reveal works accurately.
I am engaged on iPhone 13, iOS 16.0.
Code of the transition
extension CALayer {
func makeFadeTransition() {
let transition = CATransition()
transition.timingFunction = CAMediaTimingFunction(identify: .easeInEaseOut)
transition.period = 0.5
transition.sort = .fade
self.add(transition, forKey: nil)
}
}
Utilization
self.customView.layer.makeFadeTransition()
I do know that we are able to change to utilizing UIView.animate mix with alpha to vary opacity as an alternative
UIView.animate(withDuration: 0.15, animations: {
self.customView.alpha = 0.0
})
or utilizing CABasicAnimation
extension CALayer {
func makeFadeTransition() {
let transition = CABasicAnimation(keyPath: "opacity")
transition.timingFunction = CAMediaTimingFunction(identify: .easeInEaseOut)
transition.period = 0.5
transition.fromValue = 1.0
transition.toValue = 0.0
self.add(transition, forKey: nil)
}
}
However once more, is CATransitionType sort fade damaged or I am unsuitable at one thing.
Thanks in superior.
[ad_2]
