Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

作者您好,怎么取消swipeHeaderBar的顶部悬停呢,而是让它跟随下方的tableview滚动呢 #3

Open
ShyHornet opened this issue Jun 24, 2016 · 3 comments

Comments

@ShyHornet
Copy link

No description provided.

@liangdrime
Copy link
Owner

liangdrime commented Jun 24, 2016

如果不做悬停,只是普通的跟随tabelView滚动的话,只需要修改一下代码就行。
在KVO方法 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context 修改代码,去除顶部悬停位置的判断即可,如下:

if (!_swipeHeaderBarScrollDisabled) {
    CGFloat newOffsetY        = [change[NSKeyValueChangeNewKey] CGPointValue].y;
    UIView * headerBottomView = _swipeHeaderBar?_swipeHeaderBar:_swipeHeaderView;
    headerBottomView.bottom = - newOffsetY;
    if (_swipeHeaderBar) {
         _swipeHeaderView.bottom = _swipeHeaderBar.top;
    }
}

@ShyHornet
Copy link
Author

你的回复好快,谢谢帮助!已经解决

@liangdrime
Copy link
Owner

很抱歉,后来测试发现上述答案有点问题,已经修改 :fabs(newOffsetY)改为了- newOffsetY。
同时,在最新的0.2版本中这个地方要增加修改,如下:

if (!_swipeHeaderBarScrollDisabled) {
   CGFloat newOffsetY        = [change[NSKeyValueChangeNewKey] CGPointValue].y;
#if !defined(ST_PULLTOREFRESH_ENABLED)
   UIView * headerBottomView = _swipeHeaderBar?_swipeHeaderBar:_swipeHeaderView;
   headerBottomView.bottom = - newOffsetY;
   if (_swipeHeaderBar) {
       _swipeHeaderView.bottom = _swipeHeaderBar.top;
   }
#else
   UIView * headerTopView    = _swipeHeaderView?_swipeHeaderView:_swipeHeaderBar;
   headerTopView.top = - newOffsetY;
   if (_swipeHeaderView) {
       _swipeHeaderBar.top = _swipeHeaderView.bottom;
   }
#endif
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants