Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does my Quartz arcs display thicker than the straight lines?
    primarykey
    data
    text
    <p>I'm trying to create a custom UIButton that should look like a UIButtonTypeRoundedRect. In my drawRect:, I'm creating a path with first one call to CGContextMoveToPoint() and then four calls to CGContextAddArc(). I then stroke the path. However, in the resulting image the four rounded corners are clearly thicker than the rest of the path.</p> <p>I suspected this had something to do with anti-aliasing, so I tried switching it off with CGContextSetShouldAntiAlias(), but then it looked even worse. I've also tried experimenting with the line width, but the arcs are always thicker than the straight lines. Apple's UIButtonTypeRoundedRect looks perfectly fine, so it must be possible to solve somehow. Does anybody have a clue?</p> <p>Edit: the relevant code:</p> <pre><code>CGContextRef context = UIGraphicsGetCurrentContext(); CGContextBeginPath(context); CGContextMoveToPoint(context, rect.origin.x + kRoundedRectButtonRadius, rect.origin.y); CGContextAddArc(context, rect.origin.x + rect.size.width - kRoundedRectButtonRadius, rect.origin.y + kRoundedRectButtonRadius, kRoundedRectButtonRadius, 3 * M_PI_2, 0, NO); CGContextAddArc(context, rect.origin.x + rect.size.width - kRoundedRectButtonRadius, rect.origin.y + rect.size.height - kRoundedRectButtonRadius, kRoundedRectButtonRadius, 0, M_PI_2, NO); CGContextAddArc(context, rect.origin.x + kRoundedRectButtonRadius, rect.origin.y + rect.size.height - kRoundedRectButtonRadius, kRoundedRectButtonRadius, M_PI_2, M_PI, NO); CGContextAddArc(context, rect.origin.x + kRoundedRectButtonRadius, rect.origin.y + kRoundedRectButtonRadius, kRoundedRectButtonRadius, M_PI, 3 * M_PI_2, NO); CGContextClosePath(context); CGContextSetLineWidth(context, 1.7); CGContextStrokePath(context); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload