Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

completely erasing UIBezierPath & CAShapeLayer drawn items

In portrait mode (first time drawing)

enter image description here

After rotating to landscape, why are the older shapes:

enter image description here

I am using UIBezierPath & CAShapeLayer to draw circles & lines in a custom UIView's layer. The problem is inspite of being able to draw new circles & lines successfully after device is rotated, I am unable to remove the older drawn shapes. The new shapes drawn after device rotation are perfect, I just need to remove from screen those older shapes sticking in the screen. Images attached.

like image 376
ystack Avatar asked Dec 03 '14 15:12

ystack


2 Answers

You can either remove the previous CAShapeLayer (with removeFromSuperlayer) or replace the path of the previous CAShapeLayer. You would appear to be adding a new layer without removing the old one, but of course it is impossible to tell without source code.

like image 139
Rob Avatar answered Sep 23 '22 16:09

Rob


aah! found the solution using rootView.layer.sublayers = nil removed all earlier shapes

like image 23
ystack Avatar answered Sep 20 '22 16:09

ystack