2017-07-17 48 views
-1

我想在提供的圖像(右下角,藍色按鈕)中看到,在TableViewController的按鈕中添加幻燈片。它是從9gag應用程序,如果這是更有幫助。它需要像9gag中的按鈕一樣工作,所以當你向下滑動時,它會滑入視圖。當你向上滑動時,它會再次出現。我如何在Xcode中做到這一點?最簡單的解決方案就可以做到。滑入按鈕UITableView Xcode

9gag Button

+0

你有什麼試過的?你google了嗎?看看這個https://www.cocoacontrols.com/controls/vcfloatingactionbutton – Venkat

回答

0

這就是所謂的浮動按鈕。

你甚至可以實現這樣的動作:

Floating Button Control

要顯示或隱藏滾動視圖按鈕,只需檢查滾動視圖是向上或向下滾動像這樣:

CGPoint _lastContentOffset; 

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { 
_lastContentOffset = scrollView.contentOffset; 

} 

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { 

if (_lastContentOffset.x < (int)scrollView.contentOffset.x) { 
    NSLog(@"Scrolled Right"); 
} 
else if (_lastContentOffset.x > (int)scrollView.contentOffset.x) { 
    NSLog(@"Scrolled Left"); 
} 

else if (_lastContentOffset.y < scrollView.contentOffset.y) { 
    NSLog(@"Scrolled Down"); 
} 

else if (_lastContentOffset.y > scrollView.contentOffset.y) { 
    NSLog(@"Scrolled Up"); 
} 

}