Sidharth J Dev
Sidharth J Dev

Reputation: 987

Change Size of UIScrollView dynamically in autolayout

Constraints For ScrollView Constraints for ScrollView Constraints for ScrollView Constraints for ScrollView I have a UIScrollView in my app. I need the UIScrollView to change its height dynamically. I have already tried _scrollArea.contentSize=CGSizeMake(_contentView.frame.size.width, x* _contentView.frame.size.height); (with various values for x), but the scroll view is unaffected. the size of the UIScrollView is

320,568

And the size of the _contentView is

320,1100

So the UIScrollView needs a minimum height of 568 and a maximum height of 1100 (depending on certain app logic). I have embedded the whole thing into AutoLayout

NOTE:ContentView is INSIDE the UIScrollView

Upvotes: 1

Views: 1179

Answers (1)

Pritesh
Pritesh

Reputation: 980

You just need to do is take outlet of height constant and change it as per your requirement

see the below screen shots

enter image description here

now you should use below code

 self.scrollViewHeight.constant = 347; // set the height which you want to fix.

Upvotes: 2

Related Questions