Change image color with set attributes or programmatically
1. Use setting attributes UiImage
Follow this image step by step
- In image Assets.xcassets select your image
- show tab attributes inspector
- change default to template
- in viewController where you set image, change color what you want in tintColor like this image below, ex: in image set color white.
2. Change Color UiImage with Programmatically
This example of how to change color UiImageView in code
@IBOutlet weak var imageView: UIImageView!
// set in viewDidLoad
imageView.contentMode = .scaleAspectFit
imageView.tintColor = UIColor.gray
imageView.image = imageView.image.withRenderingMode(.alwaysTemplate)
No comments: