itenyh
itenyh

Reputation: 1939

how to fit the size of the imageview to it`s father view

I have a UIView and I want to add an image as it`s subview ( [view addSubview:imageView]). I want to know how to set the size of the imageView to fit the size of the UIView (By programming) . By default, the image is too large to be displayed.

Upvotes: 0

Views: 90

Answers (3)

Jeffery Thomas
Jeffery Thomas

Reputation: 42588

When a child is working within the view of it's parent, it should use the parent's bounds and not the parent's frame.

imageView.frame = self.bounds.frame

Upvotes: 1

Saad
Saad

Reputation: 8947

use this

[imageView setFrame:CGRectMake(self.view.origin.x, self.view.origin.y, elf.view.bounds..size.width, self.view.bounds.size.height)];

Upvotes: 0

rishi
rishi

Reputation: 11839

you can set the frame of image view equals to view, like -

imageView.frame = self.view.frame

Upvotes: 0

Related Questions