1

I have a view whose mask I had set earlier in some method, now I want to extract the CGPathRef which was the shape of the mask without having nothing at all, just the view with mask. How do I do that?

CAShapeLayer* maskLayer = [CAShapeLayer layer];
                maskLayer = (CAShapeLayer* )myView.layer.mask;
                CGPathRef x = maskLayer.path;

tried this, didn't work.

Shivam Tripathi
  • 1,405
  • 3
  • 19
  • 37

1 Answers1

0

You can get the path of a CALayer if its a CAShapeLayer which is a CALayer subclass so if your myView.layer.mask is not CAShapeLayer object you can't get the CGPath you can check if its the right class making a check

NSLog(@"%@",NSStringFromClass(myView.layer.mask.class));

this must print

CAShapeLayer

Reinier Melian
  • 20,519
  • 3
  • 38
  • 55