iOS 16 beta + UIImage + UIButton + tintColor no longer works

In iOS 14 and 15 I could use the .alwaysTemplate rendering mode of a UIImage and set that as the image of a UIButton. Then set the tintColor of the UIButton to change the color of the button image. However, in iOS 16 (tested with beta 3 and beta 4) it's not working.

Is this is bug with the beta? Or did something change in iOS 16? Thanks!

let templateImage = uiImage.withRenderingMode(.alwaysTemplate)
uiButton.setImage(templateImage, for: .normal)
uiButton.tintColor = .systemYellow

iOS 16 has shipped and this issue remains. Anyone else run into this?

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
    }
}
iOS 16 beta + UIImage + UIButton + tintColor no longer works
 
 
Q