Simon Z.
Simon Z.

Reputation: 37

Stretch UIView in a ContentView of a ScrollView

I have the following problem:

I have a Scrollview with Autolayout top,left,bottom,right is set on 0, in this ScrollView is a ContentView also set everything on 0. The ContentView contains a ImageView a Segmented Control and a UIView which is connected to 2 different UIViewController.

The UIView is set top 0 to the Segmented Control and to bottom 0 to the contentView.

My Problem is that the UIView in the ContentView is not streets to the bottom of the ContentView. How can i solved this Problem?

Picture 1: Storyboard UIViewController with ScrollView

Picture 2: View on an iPhone 6 Plus

Here there are the size inspector constraints pictures:

Upvotes: 0

Views: 891

Answers (1)

Yury
Yury

Reputation: 6114

Seems like the problem is in scroll view bottom content inset. By default scroll view have automaticallyAdjustsScrollViewInsets property enabled, and if you insert scroll view as nearest view to tab bar (as I can see at screenshot), bottom inset will set as nonzero (this used for show content under transparent tab bar while scrolling). But for use this behavior properly, you should connect scroll view bottom to view (root view) bottom, not to bottomLayoutGuide. Second option - disable automaticallyAdjustsScrollViewInsets property and handle contentInset and scrollIndicatorInsets properties of scroll view manually (set them to UIEdgeInsetsZero if you don't want change your constraints).

Upvotes: 0

Related Questions