hi all, i am new to iPhone. i want to get the height of a image. so i can set the frame of UIImageview accordingly. Please suggest how can i get the original size(width and height) of image.
+1
A:
You can try to check
[[UIImage imageNamed:@"myImage.png"] size].height; [[UIImage imageNamed:@"myImage.png"] size].width;
Morion
2009-11-04 11:14:04
Ok, 3 seconds faster than me, you win. :)
Pascal
2009-11-04 11:18:06
oh sorry. I wrote it from PC, not mac) so the only aim was to show a principle) anyway, thanks for correction.
Morion
2009-11-04 12:15:35
+3
A:
Well, if you have the image as UIImage
, then you want to take a look at the size
property:
CGFloat width = myImage.size.width;
CGFloat height = myImage.size.height;
Pascal
2009-11-04 11:14:07
+1
A:
Maybe this also helping you:
UIImage *image = [ UIImage imageNamed: @"image.png" ];
imageView.bounds = CGRectMake(0, 0, image.size.width, image.size.height);
zZzZ
2009-11-04 15:58:03