Note - if you need to add a true one pixel line, don't fool with an image, use this:
@interface UILine : UIView
@end
@implementation UILine
-(void)awakeFromNib
{
float sortaPixel = 1.0/[UIScreen mainScreen].scale;
// float sortaPixel = 1.0/self.contentScaleFactor;
// -- recall, that does NOT work when loading from storyboard!
UIView *line = [[UIView alloc] initWithFrame:
CGRectMake(0, 0, self.frame.size.width, sortaPixel)];
line.userInteractionEnabled = NO;
line.backgroundColor = self.backgroundColor;
line.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self addSubview:line];
self.backgroundColor = [UIColor clearColor];
self.userInteractionEnabled = NO;
}
@end
How to use in storyboard, just make a UIView that is in the exact place, and exact width, you want. (Naturally, make it stretch to width, or whatever as necessary.)
Just make the view - say - 5 pr 6 pixels high -- purely so you can see it properly. (It does not matter how high you make it on the storyboard.)
(Make the top of the UIView exactly where you want the single-pixel line.)
Make the UIView any color you want, probably black.
Change the class to UILine. At run time it will draw a perfect single-pixel line in the exact location on all devices.
Hope it helps with this in a small way.