session-ios/SessionUIKit/Utilities/UIImage+Tinting.swift

12 lines
343 B
Swift
Raw Normal View History

2020-11-09 06:03:59 +01:00
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)
}
}