UITapGestureRecognizer *scrlTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(scrlTapREcotTap:)];
[scrlTap setNumberOfTapsRequired:1];
[self.ScrollView addGestureRecognizer:scrlTap];
获取.h文件并在BOOL isTappFirstTime;
方法中写入viewDidLoad
isTappFirstTime = YES;
编写以下手势方法;
- (void)scrlTapREcotTap:(UITapGestureRecognizer *)gestureRecognizer
{
if(isTappFirstTime)
{
//put code of hide
[UIView animateWithDuration:1.0 animations:^{
button.alpha = 0;
imgView.alpha = 0;
} completion: ^(BOOL finished) {
button.hidden = YES;
imgView.hidden = YES;
}];
isTappFirstTime = NO;
}
else
{
// put code of show
[UIView animateWithDuration:1.0 animations:^{
button.alpha = 1;
imgView.alpha = 1;
} completion: ^(BOOL finished) {
button.hidden = NO;
imgView.hidden = NO;
}];
isTappFirstTime = YES;
}
}