I have an iOS (4.0) app that I would like to change the alpha of a specific UILabel of just by taping anywhere on the screen. I don't have my interface done programmatically, I just used the interface builder to place the labels for things on the screen.
How can I use a tap gesture to change the alpha of a specific UILabel in my program?
Thanks in advance!
In viewDidLoad:
UITapGestureRecognizer *oneTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    [oneTap setNumberOfTapsRequired:1];
    [oneTap setNumberOfTouchesRequired:1];
    [self.view oneTap];
Then define the method:
-(void)tapAction:(UIGestureRecognizer *)gesture 
    {
          [self.yourLabel setAlpha:0.5f]; // set the alpha to whatever you want, or animate the fade, whatever
    }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With