1 year ago
#299478
Mycroft Canner
How to draw CALayers during an animation so that they appear correctly?
Inside a LazyHStack, I use UIViewRepresentable to draw an avatar for each item.
The avatar is drawn using CALayers:
override public func draw(_ layer: CALayer, in ctx: CGContext) { draw(layer) }
func draw(_ layer: CALayer) {
[..]
}
Content mode of the UIView is set to .redraw
and it has no problem redrawing on bound changes and seems to perform well.
However when I remove and add views to the lazy stack using the default animation there seems to be a race condition that causes the drawing to happen while the view is fading in.
This causes the drawing to either not appear at all or very faintly as shown in the picture below (it won't show in a screenshot).
ios
swift
core-animation
calayer
0 Answers
Your Answer