Mostafa
Mostafa

Reputation: 1612

UIScrollView in part of the screen

In all the tutorials i have seen regarding the scroll view, they say that i should put the scroll view to cover the whole screen. I want to put a scroll view in just a part of the screen. What i have done is that i inserted scroll view and have set contents in it and then wrote those this piece of code:

scrollView?.contentSize = CGSize(width: screenSize.width, height: submitButton!.frame.origin.y +
        submitButton!.frame.height + 370)

Where Submit Button is the last button in the form.

What happened here is not exactly what i want

Screen shot The Green area is the scroll view, and the contents are scrollable but they are out of the scroll view as you can See! I want the content to be scrollable but within the green area "The scroll View"

Am i doing it in a wrong way. is the scrollview just handle the whole screen only.

Thanks for your support

PS: I am not using autolayout

Upvotes: 3

Views: 1923

Answers (1)

Pablo Carrillo Alvarez
Pablo Carrillo Alvarez

Reputation: 1182

You probably need to set clipToBounds = YES on the scroll view or if you use storyboard tick clip subviews

Upvotes: 4

Related Questions