I have an image called arrowWhite
. I want to colour this image to black.
func attachDropDownArrow() -> NSMutableAttributedString {
let im
Swift 3 extension wrapper from @Nikolai Ruhe answer.
extension UIImageView {
func maskWith(color: UIColor) {
guard let tempImage = image?.withRenderingMode(.alwaysTemplate) else { return }
image = tempImage
tintColor = color
}
}
It can be use for UIButton
as well, e.g:
button.imageView?.maskWith(color: .blue)