2015-02-07 3 views
0

하나의 이미지는 640 * 960이고 내 이미지 뷰는 300 * 300.i로 설정되어 있습니다. 이 수행 보이는 이미지 뷰 이미지 ..iOS의 이미지 뷰에서 이미지 너비와 높이를 얻는 방법

enter image description here

후 내가 이미지 뷰에서 이미지의 폭과 높이를 필요로하는 이미지보기 이미지를로드.

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); 
+0

다음 링크 - http://stackoverflow.com/questions/14620279/ios-get-width-height-of-jpg-file –

답변

0

당신은 방법 다음에 높이와 이미지의 폭을받을 수 있나요?

@import AVFoundation; 

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

나는 그것이 무엇을 찾고 있는지 생각한다.

AV Foundation Functions Reference

+0

이 또한 제공의 폭과 높이를 이동하십시오 이미지의 너비와 높이를주고 있지 않습니다. – iOSDevp

+0

은 300 * 300의 이미지를 얻고 있다는 것을 의미합니까? – anny

+0

UIImage * image = [UIImage imageNamed : @ "paint5.png"]; int height = image.size.height; int width = image.size.width; NSLog (@ "이미지의 높이는 % i이고 이미지의 너비는 % i", 높이, 너비 임); – anny

0

당신이 시도해 봤어 :

관련 문제