When I came across most of the examples, I notice almost all of them are using withRenderingMode, when assigning an UIImage to UIImageView, UIButton, ...
Examples are :-
Action Sheet with Image for each option on iOS
My initial thoughts is that, the purpose of using withRenderingMode, is to generate a new instance of UIImage, so that changing the tint color of an UI component, will not affect rest of others.
I wrote a simple program without using withRenderingMode
class ViewController: UIViewController {
@IBOutlet weak var imageView1: UIImageView!
@IBOutlet weak var imageView2: UIImageView!
@IBOutlet weak var imageView3: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
let chooseImage = UIImage(systemName: "photo")
imageView1.image = chooseImage
imageView2.image = chooseImage
imageView3.image = chooseImage
imageView1.tintColor = .red
imageView2.tintColor = .green
}
I expect all UIImageView will end up of having same image color, but it doesn't happen.
Can anyone show an example, on when using withRenderingMode is really necessary?
Thanks.
