English 中文(简体)
i 电话获得图像宽度和大小
原标题:iPhone get image width and size
  • 时间:2009-11-04 11:04:03
  •  标签:

I am new to iPhone programming. I want to get the height and width of a image, so I can set the frame of UIImageview accordingly. Any suggestions how can I get the original size (width and height) of image?

最佳回答

如果您的图像为<代码>UIImage,那么你想看<代码>size。 财产:

CGFloat width = myImage.size.width;
CGFloat height = myImage.size.height;
问题回答

你可以试图检查

[[UIImage imageNamed:@"myImage.png"] size].height;
[[UIImage imageNamed:@"myImage.png"] size].width;

或许这也有助于你:

UIImage *image = [ UIImage imageNamed: @"image.png" ];
imageView.bounds = CGRectMake(0, 0, image.size.width, image.size.height);

www.un.org/Depts/DGACM/index_spanish.htm 请问:

image.size.height;

image.size.width;
[[UIImage imageNamed:@"image.png"] size].height;
[[UIImage imageNamed:@"image.png"] size].width;




相关问题
热门标签