I'm making a strong effort to optimize my scrolling performance in a UITableViewController with some rather busy cells. Among my optimizations is differentiating between UIImageView.image and UIImageView.highlightedImage in my cells. This is to minimize alpha blending, as the original images have an alpha channel. The regular image is prerendered against a background matching the UITableViewCell's background color (white); the highlighted image retains the original image's alpha channel.
This works great when highlighting the cell, which then navigates to the Details VC. However, popping back to the Master VC looks a little weird; when the cell deselects and animates the selectedBackgroundView out, the UIImageView flips from highlightedImage to image instantly. This creates the visual noise of opaque white appearing while the animation is in progress.
Is there an easy way to:
a) have the UIImageView naturally animate the cross dissolve of the image view alongside the deselect animation?
or
b) have the UIImageView wait for the deselect animation to finish before flipping from highlightedImage to image?
As a hack right now, I've added a manual UIView.transition in UITableViewCell.setSelected(:highlighted:) with a baked-in duration of 1 second to swap the images manually. I'm not a fan of this, as it not only makes assumptions about the highlight/selection state, but it also requires additional code that's less obvious for others who will maintain my code long-term.
What is the Right™ way to do this?
(DISCLAIMER: For those who are probably thinking this is a premature optimization, the final design may have anywhere from two to ten images in each cell, all of them with the same alpha situation. Decent performance on older devices is indeed important to us.)