Change imageview height programmatically ios

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.

Upvotes: 3

Views: 6875

Answers (1)

Meet
Meet

Reputation: 1208

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

Upvotes: 6

Related Questions