Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8006063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:23:24+00:00 2026-06-04T17:23:24+00:00

I am drawing a path in my drawRect implementation on a UIView with: CGContextSetLineWidth(context,

  • 0

I am drawing a path in my drawRect implementation on a UIView with:

CGContextSetLineWidth(context, 0.5);
CGContextStrokePath(context);

With anti-aliasing on on my CGContext, I can’t seem to draw 1 px lines.

on

I tried turning antialiasing off with:

CGContextSetShouldAntialias(context, NO);

but then my corners look terrible:

off

How do I keep antialiasing on but stop this sub-pixel bluring of 1 pixel lines?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:23:25+00:00Added an answer on June 4, 2026 at 5:23 pm

    When you draw a line in iOS, you specify the coordinates of a infinitely narrow line. The drawn line will then extend to both side of that line by half the stroke width.

    If your infinitely narrow line has integer coordinates and is horizontal or vertical, the drawn line will be two pixels wide and gray instead of one pixel wide and black (with anti-aliasing). Without anti-aliasing, the line will be slightly moved but the corners look ugly.

    To solve it, use coordinates in the middle of a pixel (e.g. 200.5 / 170.5) and turn anti-aliasing on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a drawing app where the user can draw lines with their finger,
I made a simple drawing app with which I can draw lines on a
I was drawing a path into a layer. Lets say I can't access that
I'm learning drawing shapes in WPF. I want draw a Path programmatically, not through
Here is my code for free hand drawing. But when i draw the path,
What's the best practice for drawing a closed, filled path where each line has
When drawing OpenGL ES textures, they seem to snap to round pixel locations, as
- (void)drawRect:(CGRect)rect { // Drawing code. stickerImage = [UIImage imageNamed:@betaImage.png]; CGSize size = stickerImage.size;
Here's My Code: - (void)drawRect:(NSRect)dirtyRect { // Drawing code here. // Create the Gradient
I made of subclass of UIView called Bubble using which i want to draw

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.