目前,我有我的ViewController如下如何以编程方式设置这些约束?
--highestView--
--topView--
--tableView--
我想使topView
dissappear当我向下滚动,这意味着tableView
将是完全highestView
下方。
所以滚动后,我想让他们回到原来的视图,就像上面一样。
我的代码如下: -
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat scrollPos = self.tableView.contentOffset.y ;
if(scrollPos >= self.currentOffset){
//Fully hide your toolbar
[UIView animateWithDuration:2.25 animations:^{
self.topView.hidden = YES;
self.topViewTopConstraint.active = NO;
self.theNewConstraint2.active = NO;
self.theNewConstraint = [NSLayoutConstraint constraintWithItem:self.tableView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.highestView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0];
self.theNewConstraint.active = YES;
}];
} else {
//Slide it up incrementally, etc.
self.theNewConstraint.active = NO;
self.topView.hidden = NO;
self.topViewTopConstraint.active = YES;
self.theNewConstraint2 = [NSLayoutConstraint constraintWithItem:self.tableView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.topView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0];
self.theNewConstraint2.active = YES;
//self.topView.hidden = NO;
}
}
向下滚动的作品完全一样我多么希望,但向上滚动失败。目前,topView
在滚动后显示在tableView
的后面。我怎样才能解决这个问题 ?