John Doe
John Doe

Reputation: 403

IOS - how to prevent button in background from being tapped?

I have a see through UIView in front of a UIButton. There are some other UIViews on the transparent UIView that the user can interact with.

How do I prevent the user from being able to click the button in the background?

I have tried to assign first responder status to the transparent UIView, but that doesn't work and doesn't make any sense because how would the user interact with the other visible UIViews on top?

Upvotes: 0

Views: 96

Answers (2)

Sraavan reddy
Sraavan reddy

Reputation: 1

Objective -C

self.buttonName.isEnabled = YES; //button is Enabled self.buttonName.isEnabled = NO; // button is Disabled

Upvotes: 0

Kapil G
Kapil G

Reputation: 4141

just set [self.myButton setEnabled:NO]; when your transparent view is open. Enable the button when you want to allow click

self.navigationItem.rightBarButtonItem.enabled = NO;

swift version

button.isEnabled = false

for navigation bar button

self.navigationItem.rightBarButtonItem?.enabled = false

Upvotes: 1

Related Questions