Fonts and lines on the Retina display

I ended my application in @ 1x version and created a lot of interface with code, which means:

  • Uilabels
  • Uiviews

and everything looks great. if i now use the app on the retina screen, obviously everything scales to @ 2x. I have some graphics that I developed with fireworks / photoshop and, of course, made versions of 2 versions that work fine. My problem is the standard interface elements as above.

Question: How do I go

  • Is there a font in UILabel that has a 1px stroke in both resolutions but doubles the height and width by @ 2x?
  • Having a UIView with a height of 1px (like a screen splitter) at both resolutions? The 2px lines at @ 2x are fine, but the id really rather has 1px heights - it just looks more elegant.

to create the separator view that I am currently using:

UIView *separatorLine = [[UIView alloc]initWithFrame:CGRectMake(0,200,320,1)];
[self.view addSubview:seperatorLine];

which works fine at @ 1x resolution, but gets increased to 2px height at @ 2x, instead of showing in @ 2x as:

seperatorLine.frame == (0,400,640,1)

How do I need to change such code to work with both permissions?

+3
source share
2 answers

You can check the screen scale on

CGFloat scale = ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] ? [UIScreen mainScreen].scale : 1.0);

If the scale is 2.0, you are on the retina screen and you can change the frame of the separator, for example, to CGRectMake(0.0, 200.0, 320.0, 0.5).

+2
source

You don’t need to worry about this when using Apple Cocoa elements, which is the best part of retina display for us developers!

@2x , , , Cocoa . Apple "" "", . 1px 2px . , , CGRectMake(0,400,640,1), , (, ). , 1px , . 320x1, @2x 640x1.

, , , > > iPhone (Retina)

.

+1

All Articles