Search code examples
iosiphoneanimationcabasicanimationrasterize

CABasic Animation on iPhone X causes "Warping" of Rasterised Layers


I am creating an App that uses CABasic Animation on Sublayers of a UIView.

Scaling and Position Animations are involved and the Layers are CAShapeLayers with shouldRasterize set to true for smooth Animation.

This works, but on the iPhone X, Layers with Dark Colours such as UIColor(red: 0, green: 35/255, blue: 9/255, alpha: 1) appear to "warp" during the Animation.

This does NOT happen on other iPhones including the 7 Plus and 6 Plus, nor does it happen in the Simulator.

This also does NOT happen on the iPhone X if shouldRasterize is set to false, nor does it affect lighter coloured Layers.

Has anyone encountered this and/or have a solution?


Solution

  • It turned out this actually happens in all Apps with dark colours and black, as a result of the delay in turning on/off pixels when black is required.

    The only way to avoid this is to use a dark colour instead of black, with an RGB value of at least 20, which basically means the pixels don't turn off, so you have to decide whether battery-saving true black or motion is more important.