kAiN
kAiN

Reputation: 2773

Change height of UIView when UITableView Scroll

Hello everyone in my ViewController I have a UIView placed at the top and a UITableView immediately below the UITableView

I'm trying to change the height of my UIView when the UITableview scroll up

I'm trying to use this method but I can not get results .. my UIView gets stuck ... where am I doing wrong?

This is the code in use

-(void)viewDidLoad {
   [super viewDidLoad];

    _navView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, self.view.frame.size.width -20, 50)];
    _navView.backgroundColor = UIColor.clearColor;
    [self.view addSubview:_navView];
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView {

    if (scrollView.contentOffset.y >50) {
        self.navView.frame = CGRectMake(10, 20, self.view.frame.size.width -20, 0);

    } else {
        self.navView.frame = CGRectMake(10, 20, self.view.frame.size.width -20, 50);
    }

}

Upvotes: 0

Views: 349

Answers (1)

Shehata Gamal
Shehata Gamal

Reputation: 100503

You have to put inside viewDidLoad

self.tableView.delegate = self

Upvotes: 1

Related Questions