Reputation: 1939
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
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
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
Reputation: 11839
you can set the frame of image view equals to view, like -
imageView.frame = self.view.frame
Upvotes: 0