0
votes

i have one image as 640*960,and my image view has 300*300.i set the content mode the image view as aspect fit, now i load the image to the imageView it looks follow..

enter image description here

after loaded the image to the image view i need the width and height of the image from the imageView.

2
Please go through the following link- stackoverflow.com/questions/14620279/…prema janoti

2 Answers

0
votes

Did you try?

@import AVFoundation; 

UIImageView *image = [[UIImageView alloc] init];
image.image = [UIImage imageNamed:@"paint5.png"];
CGRect yourFrame = AVMakeRectWithAspectRatioInsideRect(imageView.image.size, imageView.bounds);
NSLog(@"%@",NSStringFromCGRect(yourFrame));

I think thats what u are looking for.

AV Foundation Functions Reference

0
votes

You can get height and width of image in following way:

UIImageView *image = [[UIImageView alloc] init];
image.image = [UIImage imageNamed:@"paint5.png"];
int imgHeight =  image.layer.frame.size.height;
int imgWidth = image.layer.frame.size.width;
NSLog(@"height of image %i",imgHeight);
NSLog(@"widht of image %i",imgWidth);