Change UIScrollView Content size
<p>I have ViewController with UIScrollView, some UIImages and UIButtons.
In the Storyboard I set the size of UIScrollView to: width: 320, height: 570</p>

<p>I want to change Contentsize of my UIScrollView when the ViewController was loaded.</p>

<p>I added side in the viewDidLoad:</p>

<pre><code>        scrlMain.contentSize = CGSize(width: 320,height: 790)
</code></pre>

<p>And also I added code in the viewDidLayoutSubviews:</p>

<pre><code>        self.scrlMain.translatesAutoresizingMaskIntoConstraints = true
</code></pre>

<p>But my UIScrollView is still the last size = 570.
I can't use viewDidAppear because, when I press the button, it need it to change color. When it has changed color, my UIScrollView moves to up.</p>

<p>What did I do wrong?</p>

<p>All code:</p>

<pre><code>    override func viewDidLoad() {
    super.viewDidLoad()
    scrlMain.delegate = self
    scrlMain.contentSize = CGSizeMake(320, 790)
    }
override func viewDidLayoutSubviews() {
    self.scrlMain.translatesAutoresizingMaskIntoConstraints = true
    self.scrlMain.contentSize = CGSize(width: self.scrlMain.frame.width, height: 60.0 + 5 * (self.scrlMain.frame.width / 16.0 * 5.0));
}
</code></pre>