0
votes

I'm using UIBezierPath to draw a circle like

UIBezierPath *outerPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(heigth/2.0f, heigth/2.0f)
                                                             radius:(self.frame.size.height * 0.5)
                                                         startAngle:DEGREES_TO_RADIANS(-90)
                                                           endAngle:DEGREES_TO_RADIANS(270)
                                                          clockwise:YES];
outerCircleLayer = [CAShapeLayer layer];

outerCircleLayer.lineCap = kCALineCapRound;
outerCircleLayer.lineWidth = 1.0f;
outerCircleLayer.strokeColor = HexRGB(0x4cae7b).CGColor;
outerCircleLayer.fillColor = [[UIColor clearColor] CGColor];
outerCircleLayer.path = outerPath.CGPath;
outerCircleLayer.strokeEnd = 0;

but I found the circle is not perfect,just like below

enter image description hereenter image description here

How can I do?

Updated:

Update a pic,from here we can find the start point and the end point are not smooth.enter image description here

1
What's the problem with the circles? (the image quality is so low that I can't tell if there is a problem with the shape or the angle or anything else) - David Rönnqvist
@DavidRönnqvist it's easier to find the problem when increasing the scale,just like the same problem as stackoverflow.com/questions/29063680/… - Rick
@Rick did you find any solution? - Diana Prodan
@DianaProdan sorry, the issue still exists for me - Rick

1 Answers

0
votes

While using CAShapeLayer to create a smooth circle you need to set the shouldRasterize and provide the rasterizationScale also. These are basically the attributes of CAShapeLayer.

layer = [CAShapeLayer layer];

// customize layer

// set shouldRasterize & rasterizationScale
layer.shouldRasterize = YES;
layer.rasterizationScale = [UIScreen mainScreen].scale;