iphone - Smoothing a rounded stroke in Core Graphics -


I am making my own UITableViewCells with a gradient background. I have worked all the logic and drawing, but the one that I want to fix is ​​"chunky" around the corners of my custom cell:

If you have corners, you See what I'm talking about. Here is the code that I am using to generate cells:

  CGCTXT C = UigRxGroupCertexConnect (); CGColorSpaceRef myColorSpace = CGColorSpaceCreateDeviceRGB (); CGGradientRef myGradient = Zero; CGFloat component [8] = TABLE_CELL_BACKGROUND; CGContextSetStrokeColorWithColor (C, [[UAColor colorWithWhite: 0.7 alpha: 1] CGColor]); CGContextSetLineWidth (C, 2); CGContextSetAllowsAntialiasing (C, Yes); CGContextSetShouldAntialias (C, Yes); CGFloat minx = CGRectGetMinX (RECT), MIDX = CGRactgetMIDX (RECT), MAX x = CGTXxX (RECT); CGFloat miny = CGRectGetMinY (Rect), maxy = CGRectGetMaxY (rect); CGMutablePathRef Path = CGPathCreateMutable (); CGPathMoveToPoint (path, NULL, minx, miny); CGPathAddArcToPoint (default margin of path, NULL, mix, max, midx, max,); CGPathAddArcToPoint (Default margin for path, faucet, max, max, max, minimum,); CGPathAddLineToPoint (Path, Null, Max X, Mine); CGPathAddLineToPoint (path, NULL, minx, miny); CGPathCloseSubpath (path); // Fill CGContextSaveGState (c) and stroke; CGContextAddPath (C, Path); CGContextClip (c); CGFloat locations [2] = {0.0, 1.0}; CGFloat mycomponents [8] = TABLE_CELL_BACKGROUND; CGColorSpaceRef myColorSpace = CGColorSpaceCreateDeviceRGB (); MyGradient = CGGradientCreateWithColorComponents (myColorspace, mycomponents, places, 2); CGContextDrawLinearGradient (c, myGradient, CGPointMake (minx, miny), CGPointMake (minx, maxy), 0); CGContextRestoreGState (c); CGContextAddPath (C, Path); CGContextStrokePath (c);  

What can I do to smooth the edges while continuously keeping the thickness in all the cells?

Your line width is set to 2 digits What is happening, that's your code line Calculating your bounding record without understanding the width, the result is that for every single straight segment of your size, only half of the width of the stroke is visible on the arc, the full stroke width is visible.

  CGRect rect = [self limit]  

; Rect.size.width - = lineWidth; Rect.size.height - = lineWidth; Rect.origin.x + = lineWidth / 2.0; Rect.origin.y + = lineWidth / 2.0;

For mix, midx, max x, etc. you should have the stroke similar to your calculation before and for your size.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -