简体   繁体   中英

display image in iphone 4 retina display

I am showing a high resolution image in iphone 4 and i set the image view frame size as below : imageFrameNormal.size.width = 470; imageFrameNormal.size.height = 625;

but it showing full screen instead of this size. so plz can any one suggest how i show image in right size. i am trying to check it in simulator.

Thx

You have to use the same sizes on retina and normal displays. For example, you have image view with size 100x100. On retina device you should use the same size 100x100 (no changes in your code). However you'd better use high-res image (2x size). For this you need to name it properly: image.png - normal size image image@2x.png - 2x size image.

When you call

UIImage* img = [UIImage imageNamed: @"image.png"];

image.png would be used on normal display and image@2x.png on retina (iOS does it automatically).

The retina display's coordinate system is not in pixels, but in "points". The iPhone display, whether retina or legacy will always be 320x480 points. When interacting with any parameters such as the frame, size, origin, etc., you will need to remember to use points instead of pixels. The OS will handle the "conversion" between points and pixels for you.

For a much more detailed explanation, see Points vs. Pixels in the Drawing and Printing Guide for iOS .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM