usinuniverse
usinuniverse

Reputation: 760

How do I make a UIScrollView scroll in only one direction?

I already know vertical or horizontal bounces. What I want is to prevent scrolling up.

So, only the right, left, and bottom directions are scrollable. How is it possible?

Upvotes: 2

Views: 1176

Answers (1)

Kevinosaurio
Kevinosaurio

Reputation: 2010

If you want "disable" only top bounce. You can use:

func scrollViewDidScroll(scrollView: UIScrollView) {
    if scrollView.contentOffset.y < 0 {
        scrollView.contentOffset.y = 0
    }
}

Upvotes: 2

Related Questions