在iphone5中測試應用。
復制了一張圖片,名為image1.png 和 [email protected],在iphone5中實驗,部分代碼:
UIImage *myImage = [UIImage imageNamed:@"image1.png"] ;
CGFloat imageWidth = myImage.size.width;
CGFloat imageHeight = myImage.size.height;
NSLog(@"image %f %f", imageWidth,imageHeight);
CGRect screenBound = [[UIScreen mainScreen] bounds];
CGSize screenSize = screenBound.size;
CGFloat screenWidth = screenSize.width;
CGFloat screenHeight = screenSize.height;
NSLog(@"screen %f %f", screenWidth, screenHeight);
運行之後我在控制台看見
2013-04-05 13:13:48.386 Vallabici[2413:907] image 320.000000 57.000000
2013-04-05 13:13:48.389 Vallabici[2413:907] screen 320.000000 568.000000
沒有用retina,用的是普通屏幕。
應該怎麼辦?
在retina設備中圖片的尺寸不會變,變的是規模,添加下面的log
NSLog(@"scale %f", myImage.scale);