Apply UIColor to UIImage
suggest changeReuse one template image across themes by tinting the view that displays it.
// Create a template image. The view's tintColor supplies the color.
UIImage *imgMenu = [[UIImage imageNamed:@"iconMenu"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[btn setImage:imgMenu forState:UIControlStateNormal]; // Set UIImage in UIButton.
[button.imageView setTintColor:[UIColor blueColor]]; // It changes image color of UIButton to blue color
To do the same with a UIImageView:
[imageView setImage:imgMenu]; // Assign UIImage to UIImageView
[imageView setTintColor:[UIColor greenColor]]; // Change imageview image color to green.
[imageView setTintColor:[UIColor redColor]]; // Change imageview image color to red.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents