开发者

UIScrollView- How far is it scrolled?

开发者 https://www.devze.com 2023-01-08 19:55 出处:网络
I\'m using an UIScrollView and I have an image that indicates to the user that there is more content that they can scroll through vertically. I would like this image to be hidden开发者_JAVA技巧 when t

I'm using an UIScrollView and I have an image that indicates to the user that there is more content that they can scroll through vertically. I would like this image to be hidden开发者_JAVA技巧 when the scrollview is all the way at the bottom. Is there a way to do this? Would I have to subclass UIScrollView and make my own?


your scroll view's delegate should repsond to scrollViewDidEndScrollingAnimation: and use that to check where you are

- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
  // Get some details about the view
  CGSize size = [scrollView frame].size;
  CGPoint offset = [scrollView contentOffset];
  CGSize contentSize = [scrollView contentSize];

  // Are we at the bottom?
  if (-offset.y + size.height <= contentSize.height)
    NSLog(@"bottom");
  else
    NSLog(@"not bottom");
}

NB The if statement was done in my head so it might be the wrong way round ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号