1

A quick question, how can I change the opacity (alpha value) of the Background Image of a UIButton? Thanks for the help!

@IBOutlet weak var button: UIButton!

@IBAction func Button(_ sender: Any) {
    
    button.setBackgroundImage(UIImage(named: "BG"), for: .normal)
    
}
Pressing_Keys_24_7
  • 1,755
  • 2
  • 7
  • 33
  • 1
    https://stackoverflow.com/questions/28517866/how-to-set-the-alpha-of-an-uiimage-in-swift-programmatically#:~:text=normal%2C%20alpha%3A%20value)%20let,with%20a%20transparency%20of%2050%25. Please check this link, This question has already been answered. – Kudos Nov 05 '20 at 14:19
  • @Kudos Thanks for sharing the answer:) – Pressing_Keys_24_7 Nov 05 '20 at 14:21
  • 1
    Please upvote my answer. Thanks – Kudos Nov 05 '20 at 14:22
  • 1
    Does this answer your question? [How to set the alpha of an UIImage in SWIFT programmatically?](https://stackoverflow.com/questions/28517866/how-to-set-the-alpha-of-an-uiimage-in-swift-programmatically) – Kudos Nov 05 '20 at 14:33

0 Answers0