Hilton Campbell
Hilton Campbell

Reputation: 6085

How do I draw a monochrome PDF with a tint color and opacity on iOS?

I need to draw a monochrome PDF in an iOS app, but replacing the color in the PDF with another color, and applying an opacity value. I'd like to show the result in a UIImageView or UIView.

I can draw the PDF using Quartz functions, but it is drawn black (the color of the original PDF). What would be the best way to do this?

Upvotes: 1

Views: 352

Answers (2)

Hilton Campbell
Hilton Campbell

Reputation: 6085

I was able to accomplish this in the following way:

  1. Draw the PDF into a transparent UIImage.
  2. Set that image as the contents of a new CALayer, and set the size of the layer to be the same as the image.
  3. Set the layer as the mask of a UIView's layer.
  4. Set the background color (including opacity) of the view as desired.

Upvotes: 1

Mihai Iancu
Mihai Iancu

Reputation: 1828

It is not possible to implement this using the standard iOS PDF APIs.

Upvotes: 0

Related Questions