Horizontal
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat ratio = scrollView.contentOffset.x/scrollView.frame.size.width;
_page = (int)floor(ratio);
NSLog(@"%i",_page);
if (ratio > -1 && ratio < 1) {
[_glassScrollView1 scrollHorizontalRatio:-ratio];
}
if (ratio > 0 && ratio < 2) {
[_glassScrollView2 scrollHorizontalRatio:-ratio + 1];
}
}
Vertical
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
//translate into ratio to height
CGFloat ratio = (scrollView.contentOffset.y + _foregroundScrollView.contentInset.top)/(_foregroundScrollView.frame.size.height - _foregroundScrollView.contentInset.top - _viewDistanceFromBottom);
ratio = ratio<0?0:ratio;
ratio = ratio>1?1:ratio;
//set background scroll
[_backgroundScrollView setContentOffset:CGPointMake(DEFAULT_MAX_BACKGROUND_MOVEMENT_HORIZONTAL, ratio * DEFAULT_MAX_BACKGROUND_MOVEMENT_VERTICAL)];
}