Search code examples
ioscore-graphicsantialiasing

Different colors on same 1pt line in iOS


My app has a bunch of 1pt lines in it, and I've been going through and making sure none of them are positioned in a place where iOS anti-aliases the line. However, in the image below, even though the line isn't anti-aliased, it looks like it's drawing the left & right border edges with a different shade of gray. What could be causing this?

enter image description here


Solution

  • If you just want to add borders to an UIView I think QuartzCore is the way to go. Here's an example:

    view.layer.borderWidth = 1.0f;
    view.layer.borderColor = [UIColor darkGrayColor].CGColor;
    view.layer.cornerRadius = 2.0f;
    

    Just remember to import QuartzCore (#import <QuartzCore/QuartzCore.h>). Also take a look at CALayer documentation, there are a lot other things you can do.

    Good Luck!