2017-07-03 47 views
1

私はこのコードを持っている:を隠すナビゲーションバーとツールバーサファリスタイル

#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を試しましたが、ツールバーでは動作させることができません。

サファリのようにウェブビューをスクロールしている間にバーを移動する計算をするにはどうすればよいですか。

ありがとうございました。

答えて

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]; 
} 
+0

Safariと同じ動作をアーカイブしませんが、ヘルプはありません。コードは私のものと同じです –

関連する問題