How to change font color in PDFKit

How do I change the font color in this scenario? Thanks!

    func addDateTaken(pageRect: CGRect, dateTakenTop: CGFloat) -> CGFloat {
        let dateTakenFont = UIFont.systemFont(ofSize: 12.0, weight: .semibold)
        let dateTakenAttributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.font: dateTakenFont]
        let attributedDateTaken = NSAttributedString(
            string: "Date Taken: \(dateTaken)",
            attributes: dateTakenAttributes
        let dateTakenStringSize = attributedDateTaken.size()
        let x = (pageRect.width - dateTakenStringSize.width)
        let xx = (x - x) + 20
        let dateTakenStringRect = CGRect(
            x: xx,
            y: dateTakenTop,
            width: dateTakenStringSize.width,
            height: dateTakenStringSize.height
        attributedDateTaken.draw(in: dateTakenStringRect)
        return dateTakenStringRect.origin.y + dateTakenStringRect.size.height

Better asked over at Apple developer forums, StackoverFlow, other Apple developer sites. The question is about Apple frameworks, not Swift itself.

1 Like

You could also lookup NSAttributedString in the Apple SDK references available through Xcode.

1 Like

Look up NSAttributedString.Key.foregroundColor.

1 Like

Thanks dude!!! It worked.