简体   繁体   English

使用表格滚动隐藏视图

[英]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. 因此,这个想法类似于Facebook应用中的navBar。 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. 这也不能是tableView标头或节标头。 在此处输入图片说明

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 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. 方法将帮助您轻轻地隐藏和显示视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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