3

I have this kind of structure in storyboard:

UIViewController > View > Scrollview > Scrollview > UIImageview

By Default imageview size is : 320x230. Check below image:

enter image description here

Now i need to change size of that imageview Programmatically.

Lets say i need to set frame : 320x280

Autolayout is disabled see image:

enter image description here

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.

Mayur Prajapati
  • 5,454
  • 7
  • 41
  • 70

1 Answers1

6

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

Community
  • 1
  • 1
Meet
  • 1,196
  • 12
  • 26