我有这段代码:
#pragma mark - UIScrollViewDelegate Methods
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
self.lastOffsetY = scrollView.contentOffset.y;
}
- (void) scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
{
if (self.canAnimateBars)
[self animeteBars:scrollView];
}
- (void) scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
if(self.canAnimateBars)
[self animeteBars:scrollView];
}
-(void)animeteBars:(UIScrollView *)scrollView {
bool hide = (scrollView.contentOffset.y > self.lastOffsetY);
[self.view layoutIfNeeded];
if (hide)
self.quickLinkToolBarBotom.constant = -44.0;
else
self.quickLinkToolBarBotom.constant = 0.0;
[[self navigationController] setNavigationBarHidden:hide animated:YES];
}
#pragma mark - UIWebViewDelegate Methods
- (void)webViewDidFinishLoad:(UIWebView *)webView {
self.canAnimateBars = YES;
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
NSLog(@"Error: %@", error.localizedDescription);
}
它工作正常,但想存档Safari动画的相同行为。
我已经尝试过这个库AMScrollingNavbar,但我无法使用工具栏。
在我像在Safari中滚动Web视图时,如何进行计算以移动条形图。
感谢您的帮助。
答案 0 :(得分:0)
您可以使用此代码。我认为这段代码用于你。
-(void)animeteBars:(UIScrollView *)scrollView {
bool hide = (scrollView.contentOffset.y > self.lastOffsetY);
[self.view layoutIfNeeded];
CGFloat duration = 0.3;
if (hide)
{
[UIView animateWithDuration:duration animations:^{
self.quickLinkToolBarBotom.constant = -44.0;
} completion:nil];
}
else
{
[UIView animateWithDuration:duration animations:^{
self.quickLinkToolBarBotom.constant = 0.0;
} completion:nil];
}
[[self navigationController] setNavigationBarHidden:hide animated:YES];
}