0

I'm drawing many circles using UIBezierPath and CAShapeLayer the issue is the edge of the circles are not rendered properly and it looks like a saw like in the screenshot below :

enter image description here

I tried to fix the problem by forcing the performance with this snippet but did not work:

   shapeLayer.shouldRasterize = true
   shapeLayer.rasterizationScale = UIScreen.main.scale
Ayoub Nouri
  • 201
  • 1
  • 7
  • 2
    Its not a swift issue. Its an issue wth how CAShapelayer draws circle. Try increasing rasterizationScale shapeLayer.rasterizationScale = 2*UIScreen.main.scale. You can refer [this](https://stackoverflow.com/questions/24316705/how-to-draw-a-smooth-circle-with-cashapelayer-and-uibezierpath) question. – Puneet Sharma Oct 15 '17 at 15:40
  • thanks @PuneetSharma it is much better now by increasing rasterizationScale. – Ayoub Nouri Oct 15 '17 at 15:48
  • @Ayoup Nouri: Also, if you are not animating these layers, you can simply use square UIViews with corner radius equal to size/2. That would be very smooth. – Puneet Sharma Oct 15 '17 at 15:51

1 Answers1

1

Thanks to @PunetSharma in fact i had only to increase the scale for retina devices as explained in this link to be:

shapeLayer.rasterizationScale = 2.0 * UIScreen.main.scale
Ayoub Nouri
  • 201
  • 1
  • 7