session-ios/SessionUIKit/Utilities/UIImage+Tinting.swift
2020-11-09 16:03:59 +11:00

11 lines
343 B
Swift

import UIKit
public extension UIImage {
func withTint(_ color: UIColor) -> UIImage? {
let template = self.withRenderingMode(.alwaysTemplate)
let imageView = UIImageView(image: template)
imageView.tintColor = color
return imageView.toImage(isOpaque: imageView.isOpaque, scale: UIScreen.main.scale)
}
}