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 8278477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:01:46+00:00 2026-06-08T09:01:46+00:00

See the image. The form little rectangles have different line widths. The line pointing

  • 0

See the image. The form little rectangles have different line widths. The line pointing towards the big center rect are thicker. Take the top left one for instance: the to line and the left one are thinner than the right one and the bottom one.
First I though it was an optical illusion, but no. The screenshot was taken on the Simulator at 100%.

enter image description here

The code used to draw the view below is from DrawRect() of a subclass of UIView:

public override void Draw (RectangleF rect)
        {
            rect = this.Bounds;
            CGContext oCtx = UIGraphics.GetCurrentContext();
            oCtx.SetFillColor(UIColor.Clear.CGColor);
            oCtx.ClearRect(rect);

            oCtx.SetLineWidth(2f);

            oCtx.SetFillColor(this.BackgroundColor.CGColor);
            oCtx.SetStrokeColor(this.BackgroundColor.CGColor);
            oCtx.SetAlpha(this.Alpha);

            oCtx.AddRect(new RectangleF(rect.X + HANDLE_WIDTH * 0.5f, rect.Y + HANDLE_HEIGHT * 0.5f, rect.Width - HANDLE_WIDTH, rect.Height - HANDLE_HEIGHT));

            oCtx.FillPath();

            oCtx.SetAlpha(1f);
            oCtx.AddRect(new RectangleF(rect.X, rect.Y, HANDLE_WIDTH, HANDLE_HEIGHT));
            oCtx.AddRect(new RectangleF(rect.Right - HANDLE_WIDTH, rect.Y, HANDLE_WIDTH, HANDLE_HEIGHT));
            oCtx.AddRect(new RectangleF(rect.Right - HANDLE_WIDTH, rect.Bottom - HANDLE_HEIGHT, HANDLE_WIDTH, HANDLE_HEIGHT));
            oCtx.AddRect(new RectangleF(rect.X, rect.Bottom - HANDLE_HEIGHT, HANDLE_WIDTH, HANDLE_HEIGHT));

            oCtx.StrokePath();

#if DEBUG
            oCtx.SetAlpha(0.2f);
            oCtx.SetFillColor(UIColor.DarkGray.CGColor);
            oCtx.AddRect(this.GetMovableArea(rect));
            oCtx.FillPath();
#endif
        }

Can somebody please explain why the stroke widths differ? I also tried to use StrokeRect() instead – same result. I even removed all the drawing code, except the top left rectangle without change. The constants HANDLE_HEIGHT and HANDLE_WIDTH are both set to 20f.

  • 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-08T09:01:47+00:00Added an answer on June 8, 2026 at 9:01 am

    This is due to CoreGraphics using a center pen alignment e.g. It will draw pixels either side of the line that you specify. As you have noticed bringing the co-ordinate in by half the line width will fix it.

    This article has an example and also talks about anti aliasing that iOS applies to the line and how you can avoid it.

    http://www.raywenderlich.com/2033/core-graphics-101-lines-rectangles-and-gradients

    In our case, the edge of the path is the rectangle we wish to fill. So when drawing a 1 >pixel line along that edge, half of the line (1/2 pixel) will be on the inside of the >rectangle, and the other half of the line (1/2 pixel) will be on the outside of the >rectangle.

    But of course, since there’s no way to draw 1/2 a pixel, instead Core Graphics uses anti->aliasing to draw in both pixels, but just a lighter shade to give the appearance that it >is only a single pixel drawn.

    I don’t think you can change this in CG unlike GDI+ where you can set a pens alignment http://msdn.microsoft.com/en-us/library/z62ath7a.aspx

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

Sidebar

Related Questions

I have a form that looks like the following (see image). If the user
I have many to many relationship in entity framework. See image... I want to
I have an interface that has large numbers of controls, see image below. Interface
I have a .txt file with content(see first image) I need the content in
I have placed an image on the master page. I see the image at
I have a div that contains 3 fields You can see the image here
I have 3 main elements in my XML layout (also see the image): The
I have a Windows Form with an image as a background; and I also
See the below image. I have added a reset button at the end of
How can I transform data in excel in this form (see image here: https://i.stack.imgur.com/m5EDj.jpg

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.