Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a CALayer's rounded corner content area outline as a clipping path

I can create a CALayer using [CALayer layer] and then have rounded corners using layer.cornerRadius = x.

After I do this, I have a rounded rectangle layer. Is it possible for me to extract this rounded rectangle outline as a path without re-creating the path myself?

like image 743
Ana Avatar asked Jan 14 '12 17:01

Ana


1 Answers

If you just want the path then surely it's easy enough to just make one?

UIBezierPath *roundedRect = [UIBezierPath bezierPathWithRoundedRect:layer.bounds
                                                       cornerRadius:layer.cornerRadius];

If you need to use this in CoreGraphics then just ask for it's CGPath

roundedRect.CGPath;
like image 137
Paul.s Avatar answered Oct 04 '22 02:10

Paul.s