5

I have a UIScroll view with content in it. If that content overflows, making the scroll view scrollable, I'd like to set the bottom of the view to be a certain color. If it does not, I'd like to set it to a different color.

My issue is, I do not know how to detect if a UIScrollView's content overflows and thus is scrollable.

steventnorris
  • 5,656
  • 23
  • 93
  • 174

2 Answers2

14

Check if the scroll view's contentSize is bigger than its bounds.

paulvs
  • 11,963
  • 3
  • 41
  • 66
0

I know it's an old question, but my scroll view had a content insets set which made the accepted answer slightly off. Here's how to take the content inset into account:

if scrollView.contentSize.height + scrollView.contentInset.bottom > scrollView.bounds.size.height {
    // Scroll view is able to scroll.
}
kbunarjo
  • 1,277
  • 2
  • 11
  • 27