Search code examples
uiscrollviewcalayer

CALayer with Animation on Scroll View


So, I have a CALayer added to a UIScrollView that does some path animations. In my application, I resize the scroll view and shift everything to create a "negative" region. Using contentOffset with UIScroll views, all my subviews are shifted and there is no flashing effect. However, when the lines on the CALayer are shifted, there is a flashing effect because they are drawn in the "negative" area first, then shifted over.

This was happening as an animation at first, but I used CATransaction -begin and -commit to remove the animation. The flashing is still occurring though because the lines are still drawn and then moved.

Is there anyway to solve with? Thanks in advance.

Edit: I figured out a way to fix this. Before, I was adding each animation to an animation layer, which was then added to the UISCrollView. Instead, I added each animation directly to the UISCrollView and then shift all layers appropriately as before. CATransaction -begin and -commit are still needed to remove any sort of animation of the shift.


Solution

  • I figured out a way to fix this. Before, I was adding each animation to an animation layer, which was then added to the UISCrollView. Instead, I added each animation directly to the UISCrollView and then shift all layers appropriately as before. CATransaction -begin and -commit are still needed to remove any sort of animation of the shift.