Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opacity of a custom UIButton

By default, we get the opacity of UIButton set to NO. Can we set it to YES?

like image 734
Abhinav Avatar asked Apr 22 '11 02:04

Abhinav


People also ask

How do I change the opacity of a clicked button in Swift?

@IBAction func KeyDownPressed(_ sender: UIButton) { sender. alpha = 0.5 } @IBAction func keyPressed(_ sender: UIButton) { sender. alpha = 1 playSound(col : sender. currentTitle!) }

What is UIButton in swift?

A control that executes your custom code in response to user interactions.


2 Answers

Um... opacity is not a boolean value. It is a float in the range from 0.0 (fully transparent) to 1.0 (fully opaque). The property is actually called the alpha, so you'd do:

[myButton setAlpha:0.42];
like image 155
Dave DeLong Avatar answered Sep 19 '22 06:09

Dave DeLong


setAlpha doesn't work in In swift:

photoButton.alpha = 0.3
like image 42
Esqarrouth Avatar answered Sep 21 '22 06:09

Esqarrouth