Use This code :
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UILabel *headerLabel = [[UILabel alloc]init];
headerLabel.tag = section;
headerLabel.userInteractionEnabled = YES;
headerLabel.backgroundColor = [UIColor salmonUser];
headerLabel.text = [NSString stringWithFormat:@"Interesteds"];
headerLabel.frame = CGRectMake(100, 0, 120,tableView.tableHeaderView.frame.size.height);
[headerLabel setTextAlignment:NSTextAlignmentCenter];
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(upSwipe:)];
[swipeLeft setDirection: UISwipeGestureRecognizerDirectionUp ];
[headerLabel addGestureRecognizer:swipeLeft];
swipeLeft=nil;
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(downSwipe:)];
[swipeRight setDirection:UISwipeGestureRecognizerDirectionDown];
[headerLabel addGestureRecognizer:swipeRight];
return headerLabel;
}
I have used two different method to take action individually for up and down swipe as
upSwipe
anddownSwipe
. This will simplefy the code.
-(void)upSwipe:(UISwipeGestureRecognizer *)gesture
{
[UIView animateWithDuration:0.3
delay:0.3
options: UIViewAnimationCurveEaseOut
animations:^{
CGRect rect = self.view.frame;
rect.origin.y = self.view.frame.size.height-(self.view.frame.size.height/2);
self.usersView.frame = rect;
mostrada =true;
}
completion:^(BOOL finished){}];
}
-(void)downSwipe:(UISwipeGestureRecognizer *)gesture
{
[UIView animateWithDuration:0.3
delay:0.3
options: UIViewAnimationCurveEaseOut
animations:^{
CGRect rect = self.view.frame;
rect.origin.y = self.view.frame.size.height-(self.view.frame.size.height/11);
self.usersView.frame = rect;
mostrada=false;
}
completion:^(BOOL finished){
}];
}