I have a bunch of UIViews to which I add shadows via their layers, in their drawRect method:

self.layer.shadowPath = path;
self.layer.shadowColor = [[UIColor blackColor] CGColor];
self.layer.shadowOpacity = .6;
self.layer.shadowOffset = CGSizeMake(2,3);
self.layer.shadowRadius = 2;

This works well, but my problem is I also need to create a PDF with those views. I'm doing this by creating a PDF context and passing it to the drawing method so that the drawing happens in the PDF context. That also works well, except that the shadows are not rendered in the PDF. I've experimented with a couple approaches, but haven't managed to find a proper, easy way to get those shadows to appear where they belong in the PDF.

Would anyone know how to do this?

有帮助吗?

解决方案

You will need to make the relevant CoreGraphics calls in the drawrect to draw the shadows rather than using the CALayer properties.

Check out the Apple docs on shadows.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top