Adam J
Adam J

Reputation: 45

Programmatically set size of UIView from Storyboard

I have placed UIView in UIScrollView in Storyboard. The UIView is pinned to the all the sides of the UIScrollView. I am trying to set the size of UIView programatically because it is needed for scrolling to work properly. How can I programmatically set the width and height of the UIView? Thanks for any help as I am trying to solve the problem already for a week...

Upvotes: 0

Views: 3744

Answers (2)

Henit Nathwani
Henit Nathwani

Reputation: 442

You'll need to change the frame of your view as below:

yourView.frame = CGRectMake(x,y,calculatedWidth,calculatedHeight);

Plus, you'll also need to check for the scroll view's frame so that it enlarges as per your view's width and height.

Upvotes: 1

Sergey  Pekar
Sergey Pekar

Reputation: 8745

You need to set new frame to change width, height, x or y for example:

view.frame = CGRectMake(view.frame.origin.x, view.frame.origin.y, newWidth, newHeight);

Upvotes: 0

Related Questions