How to change image color (tintColor) in iOS and WatchKit using Swift
Hello everyone! I'm a beginner in iOS development and I'm facing a problem. I want to dynamically change the color of an icon in my app based on user actions. For example, I have a star image (PNG with transparency), and I want it to turn yellow when the user taps the "Favorites" button, and gray when they deselect it.
I tried using the `tintColor` property on UIImageView, but it doesn't work as I expected. Here's my code:
```swift
let imageView = UIImageView(image: UIImage(named: "star"))
imageView.tintColor = UIColor.yellow
imageView.image = imageView.image?.withRenderingMode(.alwaysTemplate)
```
After this, the image turns yellow, but the edges look blurry, and in some places the color is applied incorrectly. I've read