In a test application, I tried the following:
CGFloat desiredWidthInPixels = 1.0f; CGFloat lineWidth = desiredWidthInPixels / [[UIScreen mainScreen] scale]; NSLog(@"lineWidth = %f", lineWidth);
I got a line of width 0.5f, which should exactly translate to one pixel width on the screen (since the scale is 2.0, which indicates a Retina device). This should properly adapt to devices of different screen sizes.
*** Caution: Of course, this only works as long as the [[UIScreen mainScreen] scale] works as it is now.
source share