I ended up going with a solution similar to the "pre iOS 13" method here: https://sarunw.com/posts/how-to-change-uiimage-color-in-swift/
extension UIImage {
func withColor(_ color: UIColor) -> UIImage? {
UIGraphicsBeginImageContextWithOptions(size, false, UIScreen.main.scale)
let drawRect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
color.setFill()
UIRectFill(drawRect)
draw(in: drawRect, blendMode: .destinationIn, alpha: 1)
let tintedImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return tintedImage
}
}
Topic:
Programming Languages
SubTopic:
Swift
Tags: