Reputation: 2535
I need to prevent the user do press a button, during an animation I run. I don't want to hide the button, or to change it's image. I can't use enabled = false, because I use this option to another situation, and it has different image.
I did try to cover the button with transparent Image, but it seems to not work, only real images can hide the button and prevent from the user to press on it.
The code that didn't work:
skipBTN.enabled = FALSE; //this one is not good for me
skipBTN.hidden = TRUE; //this one is also not good for me
This one didn't actually worked (The user still can press the button)
buttonsCover = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"empty"]];
buttonsCover.frame = button.frame;
[self.view addSubview:buttonsCover];
buttonsCover.hidden = YES;
and when it needed:
buttonsCover.hidden = NO;
I need another idea please :)
Upvotes: 0
Views: 160
Reputation: 1865
To disable
the button without changing it's appearance, i recommend:
skipBTN.userInteractionEnabled = FALSE
See also: Documentation
Upvotes: 1
Reputation: 318934
You have quite a few options but the simplest would be to use disabled
. To solve the issue of the button appearing differently when it is disable, use the UIButton setImage:forState:
(or other appropriate method) and specify a state of UIControlStateDisabled
. By setting the same image you used for the UIControlStateNormal
state, the button will look the same when disabled.
Upvotes: 0