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

1

0

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?

Primaveria answered 2/3, 2023 at 12:48 Comment(0)
C
1

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.

Catalonia answered 2/3, 2023 at 12:53 Comment(7)
For some reason, however, I am observing a behavior in my project where this is completely not the case... I have a UIButton with an image set to it. The Image is Default. Yet UIButton renders it as an original image, not a template.Markitamarkka
It depends on the button type. That's why I didn't go into the details. (You'll notice I said nothing about UIButton.) Yours is probably a .custom button. See my book if you want a complete list.Catalonia
Well, that seems like quite a vital omission... Yes, indeed, my button does appear to be of type: .custom.Markitamarkka
I didn't "omit" anything. My answer doesn't attempt to give a complete list. The examples I give are right, and they are hedged with "for example" — deliberately. If you don't like that, don't accept it. I really don't care. You asked what "where" and "context" mean and I told you, illustrating the point with a few examples. Take it or leave it. As I say, all this info is available to you complete if you really want it.Catalonia
Oh, I guess I really wasn't clear enough in the question then, as I really wanted to get something extensive. And with you answer, I assumed that it must be the complete answer and there is no more to the matter. Seems, it's just a simple misunderstanding.Markitamarkka
Just unaccept my answer so I can delete it.Catalonia
??? no, why, it's good enough :)Markitamarkka

© 2022 - 2024 — McMap. All rights reserved.