I have the following code in a prototype application that displays text with a link and presents it in a PDFView.
let a4SizePageRect = CGRect(x: 0, y: 0, width: 595.2, height: 841.8)
let renderer = UIGraphicsPDFRenderer(bounds: a4SizePageRect)
let title = "Some Title Link"
let attributedTitle = NSMutableAttributedString(string: title, attributes: [
.font: UIFont.boldSystemFont(ofSize: 24),
.link: "<insert here some correct link>",
.underlineStyle: NSUnderlineStyle.single.rawValue
])
let data = renderer.pdfData { ctx in
ctx.beginPage()
attributedTitle.draw(in: a4SizePageRect.insetBy(dx: 25, dy: 25))
}
pdfView.document = PDFDocument(data: data)
The link only works on iOS 15 versions, but does not work on iOS 16.4 and iOS 17 RC.
Based on the documentation for the property and NSAttributedString, the link attribute should still work.
Has NSAttributedString stopped supporting NSAttributedString.Key.link in recent versions of iOS?