Hi I want to make rullar in iphone.
Que: How to draw lines through UILabel in scrollView 1 inch. or 1 cm. apart from each other.
I know there are 163 pixels per inch(ppi). in 480-by-320-pixel.
But I am not sure about all version of iPhone .
Does the size of pixels are same for all its model???
Drawing in iOS uses point values rather than pixels; in a retina display there are four pixels (2x2) in a point and in a non-retina display there is one. The screen sizes are the same (with the obvious exception of the iPads). If you draw a line from (0,0) to (0,100) it will be the same length on the screen of the iPhone 4 and iPhone 3GS.
Related
The title mostly says it all;
I've got some mockups i am looking at, and as I try to implement them, It seems as though the custom drawing, even with a linewidth of 0.5, is not quite as sharp as the mockup appears when i preview it on my device. Can assets be sharper then what is possible to manually draw using quartz?
Can assets be sharper than what is possible to manually draw using quartz?
No. If that were the case, the iOS graphics system would be spectacularly broken.
Perhaps if you showed your custom drawing code, and an image of what it outputs, we could suggest something. Also, are you working with a "Retina" device?
This is most likely because of the resolution of the screen. The MacBook Pro and iMac without Retina display have approximately 110 pixels per inch and with Retina about 220, whereas the iPhone with Retina has 326 pixels per inch.
When you do coordinates in points and use whole numbers, it is as if the iPhone is 158 pixels per inch (meaning a width of 1 will be 1/158 inches wide) while on your computer it is most likely 110 pixels per inch (which is about 1/110 inches wide). However, since you are using a width of 0.5, a non-retina screen will stay at the same resolution as a width of 1.0 would be, however your device, which is most likely retina, is displaying a line with a width of 0.5 points, which is one pixel.
Because of this, a line with a width of 0.5 points will be 1/326 inches on a Retina device, but will be about 1/110 inches on your computer, which means that the line on the device will be about 3x sharper.
So i am using tiled to create levels for my new iphone game.
The when creating a map with tiled for iphone the correct map size is 50x50 and tile size 32x32.
The problem is with these dimensions the tiles are to small for what i need it for.
So i have tried doubling the settings to map size 100x100 and tile size 64x64 but no luck..
Anyone familiar with doing this?
The goal is i would like the tiles to be bigger and take up more of the screen space. If you dont get the settings right, the map wont show up correctly on the screen half of it will be hanging of.
There's two things to consider: the size of your tiles must match the tile size setting in Tiled, otherwise they will not align correctly. If you double tile size to 64x64 you also have to double the size of the tileset image.
The other thing is how many tiles fit on the screen. If you divide 480 by 64 you get 7.5 meaning 7 and a half tiles fit on the screen on the horizontal direction (assuming landscape mode). If that's what you need, you'll have to make sure the tile size is clearly divisible by 480x320 respectively 1024x768 on iPad or 568x320 on widescreen devices.
I have decided to have 2 set of images for my iPod game. One with 320x480 and the other for the retina one. I can switch happily between them but this forces me to add extra code to handle the change in resolution.
My game is played in screen space on a grid, so, if I have 32 pixel tiles, I will have to use 32 offsets in low res and 64 in retina (because of doubling resolution). For a simple game this can be no problem, but what about other more complex games? How do you handle this without hardcoding things depending on the target resolution.
Of course an easy way to bypass this is just releasing a 320x480 version an let the hardware upscale, but this is not what I want because of blurry images. I'm a bit lost here.
If you have to, you can do the conversion from points to pixels (and vice versa), easily by either multiplying or dividing the pixel/point position with the contentScaleFactor of your view. However, normally this is done automatically by you if you just keep it to using points instead of pixels.
This is automatic. You only need to add image files suffixed '#2x' for the retina resolution.
Regarding pixels, from your program you work in points which are translated to pixels by the system. Screen dimensions are 320x480 points for iphone retina and non-retina.
In the past I always see that the property called position and positionInPixels are the same. This time position * 2 == positionInPixels. Who can tell me what's the difference between these 2 properties or when their value will be different?
position is in points and positionInPixels is in pixels. On non-retina device 1 point = 1 pixel. On retina device like iPhone 4/4S and the New iPad, 1 point = 2 pixels.
Per iOS Human Interface Guidelines:
Note: Pixel is the appropriate unit of measurement to use when discussing the size of a device screen or the size of an icon you create in an image-editing application. Point is the appropriate unit of measurement to use when discussing the size of an area that is drawn onscreen.
On a standard-resolution device screen, one point equals one pixel, but other resolutions might dictate a different relationship. On a Retina display, for example, one point equals two pixels.
See "Points Versus Pixels" in View Programming Guide for iOS for a complete discussion of this concept.
position gives you a position in points, whereas positionInPixels gives you the position in pixels. On an iPhone 4, e.g., position can range from (0,0) to (320, 480) (in portrait mode); positionInPixels can range from (0,0) to (640, 960) to reflect the higher resolution its retina display.
Basically, they are different on retina display devices; they are the same on non retina display devices.
Hope this helps...
When you use Retina display your canvas still consists of 320x480 points but each point is composed of 2 pixels. In the standard display each point is one pixel. This is why retina display is more detailed as more pixel data can be used in textures. So position in pixels refers to the position on a specific pixel. (i.e. point 0 can be pixel 0 or pixel 1 in high retina display)
I had an epiphany just now.
In some places in my very first iPhone app I have hardcoded values referring to the screen width and/or height (320, 460).
now I realize that i never noticed this because in the iPhone 4 simulator i dont notice any drawing issues.
So does this mean the iPhone 4 internally converts 320 to be whatever the width for its screen resolution? i doubt it. But then again, why would i be seeing everything appearing to be fine when i run?
Example:
If I make a ball draw at position (320, 100) I can clearly see that it is drawing at the far right edge of the screen.
What is going on here?
No it does not adapt the screen it's standard 320 for the iphone. It actually adapts the simulator to the mac screen makes it bigger. And about the ball 320 is from left to right 0---320, and the 460 is from up to down 0----460. sow putting the ball at 320,100 should place it in the fa right.