I am really disappointed by the way UIImageView displays the image.
I have following piece of code:
UIImageView *imgview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 300, 100)];
imgview.image = [UIImage imageNamed:@"img.JPG"];
imgview.backgroundColor = [UIColor greenColor];
imgview.contentMode = UIViewContentModeScaleAspectFit;
[self.view addSubview:imgview];
What I get is a following screenshot:
http://img26.imageshack.us/img26/3686/screenshot20130123at629.png
[image is stretched to full width of UIImageView and does not even take full height]
Original image:
http://img248.imageshack.us/img248/341/screenshot20130123at638.png
Setting the size must occur AFTER setting the contentMode
[imageView setContentMode: UIViewContentModeScaleAspectFit];
imageView.frame = CGRectMake(x, y, width, height);
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