I have this kind of structure in storyboard:
UIViewController > View > Scrollview > Scrollview > UIImageview
By Default imageview size is : 320x230. Check below image:

Now i need to change size of that imageview Programmatically.
Lets say i need to set frame : 320x280
Autolayout is disabled see image:

Here is what i have done:
override func viewDidLayoutSubviews(){
super.viewDidLayoutSubviews()
imgThumbnail.frame = (frame: CGRectMake(0, 0, self.result.width, 280))
}
But its not working at all. Its not changing size of imageview. One more important thing is when i scroll down & up the scrollview. It takes the new frame which i have set in above code in imageview.
It will be great if someone guide me resolve this issue.
Thanks in advance.
Set imageView Autoresizing Property to None and height to required height as follows:-
imageView.autoresizingMask = .None
imageView.frame.size.height = 280.0
To better understand Autoresizing Masks refer this link :- Autoresizing masks programmatically vs Interface Builder / xib / nib
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With