steventnorris
steventnorris

Reputation: 5896

How do you tell if a UIScrollView content overflows

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.

Upvotes: 5

Views: 1780

Answers (2)

kbunarjo
kbunarjo

Reputation: 1375

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.
}

Upvotes: 0

paulvs
paulvs

Reputation: 12053

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

Upvotes: 14

Related Questions