Skip to content

Instantly share code, notes, and snippets.

@pilgwon
Created August 22, 2014 06:46
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save pilgwon/80626209e21099894957 to your computer and use it in GitHub Desktop.
if(scrollView.tag == 200) {
int page = floor(scrollView.contentOffset.x / kSlideImageWidth);
float hRatio = (scrollView.contentOffset.x - kSlideImageWidth * page) / kSlideImageWidth;
if(page == [placeImageList count]-1) return;
NSDictionary *currentImageInfo = [placeImageList objectAtIndex:page];
NSDictionary *nextImageInfo = [placeImageList objectAtIndex:page+1];
float currentHeight = [[currentImageInfo objectForKey:@"height"] floatValue] / [[currentImageInfo objectForKey:@"width"] floatValue] * kSlideImageWidth;
float nextHeight = [[nextImageInfo objectForKey:@"height"] floatValue] / [[nextImageInfo objectForKey:@"width"] floatValue] * kSlideImageWidth;
float newHeight = currentHeight + (nextHeight - currentHeight) * hRatio;
[scrollView setFrame:CGRectMake(0, 0, kSlideImageWidth, newHeight)];
[detailView setFrame:CGRectMake(0, newHeight + 10, detailView.width, detailView.height)];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment