I am trying to convert IOS points to real length(inches).
Im testing this on the New iPad. according to the spec. its width is 7.31 inches and in xcode it has 768 Points, which means it has 768/7.31 = 105 points per inch (horizontally).
From the calculation, a 105-point horizontal line should be displayed as 1 inch on physical screen.
However, when i draw on the screen and measure the distance its shorter that calculated.
Am I missing something here?
Thanks,
From the specs, the 7.31 inches is the total width of the device, not the screen. There is a bezel around the screen to allow the user to hold the iPad without touching interface controls on the screen.
Also, if scroll down a bit, you'll see that the screen is
2048-by-1536 resolution at 264 pixels per inch (ppi)
Related
I spent hours of searching about this topic, but nothing is exactly dealing with my problem. Maybe you guys can help me better.
I want to ask what is the proper way of designing a layout to properly support all the iPhones. Also the easiest way for me as possible.
My style is that I am designing for the smallest device first and then scale things up for the other devices. Is that alright or is this not how it is supposed to be done?
My problem is that I am creating a layout that should scale up according to display size.
I will give an example of Original iPhone which has screen of 320 x 480 points (which equals 320 x 480 pixels) and iPhone 6, which has screen of 375 x 667 points (which is 750 x 1334 pixels because of the different pixel density).
Now I want to make a button or textbox or rectangle (whatever) on the Original iPhone that will get bigger if I launch it on bigger device like iPhone 6.
So if I have a button having height of 30 (pt) on Original iPhone, it should be bigger on iPhone 6. But how much bigger?
Do I have to calculate those 30 pt into pt on bigger device myself every time, or is there better method that works automatically so I don't have to re-count all the dimensions for every device? What is the correct way?
Btw: I am aware of that when designing the icons, buttons, or anything that is a .png file, I have to create them in dimensions of 1x, 2x and 3x so it can scale on all the devices, but how to work with these while constructing the actual layout?
What is the logic or how is it ment to be done?
THIS PICTURE is showing the dimension proportions I found on the web and little bit of idea of my problem below.
EDIT: Please look at this website: https://designcode.io/iosdesign-guidelines
It seems like there are some Apple's measurement standarts in (pt).
For example on one of the pictures they are showing that the margin from the sides should be 8pt. Since [pt] is an universal unit, I would expect it to adapt on other devices. So if I set the margin of 8 in editor, will it make different ammount of pixels on the other devices so it looks visually the same?
If you calculate every view like this one , it will not work.
Just set constrains on that view which you want same in other devices.
Like if you fix a view's height is 30 then it will 30 in every device. It is not going to be bigger or smaller in other devices.
But if you think that, a view is 20 pixel from right and 20 pixel from left, 10 pixel from top bar and bottom layout then this view gonna same ratio in every device.
I hope you understand what i want too say.
Please comment if i am unable to make you understand. :)
This might sound silly but when i'm working with sizes in Xcode, the total frame size is equal to 320 * 568 ( width * height ). I'm fine with that. But the resolution of the phone is actually different. The iphone 4S is 640*960 & the 5 and next generations are 640*1136.
I know the last one is exactly double of what xcode is using as units, so my question is :
What unit of measurement does XCode use? If it pixels, why not use the
phone size/resolution as reference?
It uses points.
In retina devices, 1 point equals four pixels. In non-retina devices, 1 points equals 1 pixel.
Check out apple's documentation on drawing and printing on ios.
https://developer.apple.com/library/ios/documentation/2ddrawing/conceptual/drawingprintingios/GraphicsDrawingOverview/GraphicsDrawingOverview.html#//apple_ref/doc/uid/TP40010156-CH14-SW7
Specially the section "Points Versus Pixels"
Edit
To answer your iphone 4S vs 5 and next generation question. These are actual screen sizes. The resolutions are different. The iPhone 4S and 4 screens are 320x480 points, or 640x960 pixels. iPhone 5, 5C and 5S screens are 320x568 points, or 640x1136 pixels. If you are working with xibs, you may be seeing one of the previous sizes because xibs have a size defined. That's where auto layout constraints come in. You tell in the xib or storyboard how you want the elements to be resized/relocated in the screen. You may be using struts and springs to decide how to relocate items in your view instead of auto layout. It's ok.
Even if your xib / storyboard is iphone5 size, if you check the size of the screen in your viewDidAppear methods when running the app on a iPhone4/4S simulator or device, you will see that your view bounds have the size of the corresponding device.
It's better to use points instead of pixels because it helps the developer abstract from resolutions. You don't have to bother about how many pixels are a point, you just locate items at points in the screen and let the system take care of the resolution for you.
Xcode 10.1, Swift 4.2 answer
Xcode uses points. But in case of next explanation what is point and how much pixels in point -> it depends what retina device are you using. Basicaly on non-retina devices 1 point = 1pixel. On iphone 6plus and newer "plus" models, apple added 3x resolution.
On normal retina devices 1 point = 4 pixels, NOT 2!!
then apple packing that pixels into point.
At iPhone plus models apple also uses downsampling with factor 1.15 which means for example, if you have 1242*2208 then it should be devided on 1.15 and you get your 1080*1920 fullHD on your device.
https://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions
I believe that the top answer, which is:
It uses points. In retina devices, 1 point equals two pixels. In non-retina devices, 1 points equals 1 pixel.
is wrong because of outdate.
I provided a link to developer.apple.com.
https://developer.apple.com/documentation/uikit/uiscreen/1617836-scale
See also UIKit Size (Points) and UIKit Scale factor: https://developer.apple.com/library/archive/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/Displays/Displays.html
I have used CGRECTMAKE to position an image onto the 'camera' screen and was wondering whether there is a calculation ratio to convert a 4 image placement to a 4s
Iphone 4 screen is 320 480
iphone 4s screen is 640 960
I have tried just doubling my values but that doesnt seem to work so thought someone may know a formula to convert them
I cannot use AUTOLAYOUT or PLACE IMAGES ON SCREEN in storyboard as i am placing an image onto the camera screen..have tried these but no joy
thanks in advance
Not sure if I get your question correct but CGrectMake utilizes points, not pixels. Since the screen on i4 has the same size as the screen on i4s, There should be no implementation differences.
You should use 320*480 measures. The screen is devided into 320*480 points for i4/i4s
I am testing my app in the iphone simulator To test the retina display, I've set the hardware to iphone(retina)
Unfortunately, the entire scene seems to be scaled to four times its normal size!
The only thing I see, is the left bottom quarter of the entire scene.
The app, since it exceeds the bounds of the screen, shows up only as a quarter on the iphone screen.
I am using Cocos2d. What is the cause of this? I also have retina display enabled in the app delegate. Any help is greatly appreciated!
The simulator is increasing to four times it's normal size (twice on each axis) because by default it uses a 1:1 mapping of pixels.
In other words, one screen pixel = one device pixel. So when you go to Retina display, which doubles the retina density, you need four times as much space to display the device screen.
Edit:
In response to the updated question, you can use the 'scale' feature. Window->scale->50% (or command+3).
I want to create blocks for a iphone/ipad) game. I want to use same model so i need screen sizes for coding.
For example iPhone has 320 pixels in X coordinate. we have 8 blocks, so 320/8 = 40 iphone has 480 pixels in Y coordinate. we have 12 blocks, so 480/12 = 40
ipad has 768 pixels in X coordinate. we have 8 blocks, so 768/8=96
ipad has 1024 pixels in Y coordinate. we have 12 blocks, so 1024/12=8
But i want to ask to program for pixels. It understands which device is running so define pixels otomatically. How can i do it?
You could simply ask for the UIApplication's window size.
[UIApplication sharedApplication].keyWindow.bounds
Keep in mind that the value returned here is measured in points not pixels. That means that the size is the same regardless of resolution (i.e. an iPhone 3G screen and an iPhone 4 screen measure the same even though the iPhone 4 has twice as many pixels)
For non-retina screens one point = one pixel. On retina screens you would need to check for the screen's scale to determine the conversion to pixels.