简体   繁体   中英

Hidding view with table scroll

I'm searching for idea how to implement a table view with moving view on top of it. So the idea is something similar to navBar in facebook app. When you scroll up this (red) view is moving up and hiding, when you scroll up its going up and when you scroll down its revealed. This is not nav bar so most of the pods I've found are not working in this situation. This cannot be tableView header or section header as well. 在此处输入图片说明

You need added this view above table:

[self.tableView.superview insertSubview:view aboveSubview:self.tableView] 

Or you can do it in storyboard. When you table scroll down hide view, when up show.

[view setHidden:YES];

Also u could change table inset to the top of the superview.

self.tableView.contentInset = self.tableView.scrollIndicatorInsets = UIEdgeInsetsMake(self.tableView.contentInset.top -,                                                                                   self.tableView.contentInset.left, self.tableView.contentInset.bottom, self.tableView.contentInset.right);

Take a look at this library, it does exactly what you want to do

https://github.com/telly/TLYShyNavBar

I think fast way to do it use gesture recognizers to recognize reveal and hide actions and than you can use methods like below,

[UIView animateWithDuration:0.5 animations:^{
    [attachedView setAlpha:0.0f];
} completion:^(BOOL finished) {
    [attachedView setHidden:YES];
}];

and for reveal attached view

[UIView animateWithDuration:0.5 animations:^{
    [attachedView setAlpha:1.0f];
} completion:^(BOOL finished) {
    [attachedView setHidden:YES];
}];

methods will help you to hide and reveal views gently.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM