'How to programmatically change the button foreground color in Xcode?

I have a button with a system image and no Title string. I want to programmatically change the foreground color of the system image. I tried

myBtn.setTitleColor(UIColor.systemYellow, for: .normal)

This doesn't work. I know I can change the foreground color using the Interactive Builder. In the button's Attribute Inspector, there's a Foreground field that allows me to change the foreground color, but I can't find the method that accesses that attribute.

Attribute Inspector Picture

Regards, Tim



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source