Skip to content

Instantly share code, notes, and snippets.

@rbreve
Created November 10, 2016 22:09
Show Gist options
  • Select an option

  • Save rbreve/ca1fc9618987b79e862aff988efcfc15 to your computer and use it in GitHub Desktop.

Select an option

Save rbreve/ca1fc9618987b79e862aff988efcfc15 to your computer and use it in GitHub Desktop.
Floating view inside UIScrollView
CGPoint currentOffset;
//Save the initial scrollview offset when adding floating view on the UIScrollView
currentOffset = scrollView.contentOffset;
- (void) scrollViewDidScroll:(UIScrollView *)scrollView{
CGRect frame = self.floatingView.frame;
frame.origin.x -= (currentOffset.x - scrollView.contentOffset.x);
frame.origin.y -= (currentOffset.y - scrollView.contentOffset.y);
self.floatingView.frame = titleFrame;
currentOffset = scrollView.contentOffset;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment