Search code examples
uikituiimageviewuiimage

`UIImage.RenderingMode.automatic` - how does it choose the actual mode?


As per Apple docs, the rendering mode of .automatic for a UIImage leads to a behavior where the image is drawn "using the context’s default rendering mode".

What is this "context's rendering mode"? What is this "context"? How do I change its rendering mode?

Also, I have found another antique SO question about this matter, and the answer referred to some tutorial by Steven Beyers on captechconsulting.com and there it said:

UIImageRenderingModeAutomatic automatically decides which rendering mode to use based on where the image is being displayed. This is the default value for images.

What is the criteria of "where"? What makes a difference that drives the decision?

Overall, HOW does UIImage.RenderingMode.automatic decide how to render?


Solution

  • It's the surrounding display mechanism. A bar button item wants to tint the image as a template, but an image view wants to display the original image (for example). The automatic setting simply lets that behavior happen. Explicit settings override it.