Sam Jarman
Sam Jarman

Reputation: 7377

Button with Tag

How do I get a button with the a specifyed tag

id like to then cast it to a UIButton, and change the alpha

Upvotes: 1

Views: 3133

Answers (2)

vntstudy
vntstudy

Reputation: 2048

UIButton *button=(UIButton *)[self.view viewWithTag:tag];
button.alpha=0.5;

Upvotes: 6

kennytm
kennytm

Reputation: 523184

 UIView* view = [theViewContainingThatButton viewWithTag:tag];
 view.alpha = 0.5;

You don't need to cast the view to a UIButton to change its alpha. But you can add a (UIButton*) cast if really needed.

Upvotes: 1

Related Questions