uibutton - How to set the alpha of an UIImage in SWIFT programmatically? - Stack Overflow

PHOTO EMBED

Fri Jun 10 2022 20:24:09 GMT+0000 (UTC)

Saved by @leo #swift

// UIImage+Alpha.swift

extension UIImage {  

    func alpha(_ value:CGFloat) -> UIImage {
        UIGraphicsBeginImageContextWithOptions(size, false, scale)
        draw(at: CGPoint.zero, blendMode: .normal, alpha: value)
        let newImage = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return newImage!   
    }
}
content_copyCOPY

https://stackoverflow.com/questions/28517866/how-to-set-the-alpha-of-an-uiimage-in-swift-programmatically