Methods to allow using HTML code with CoreText
Swift
6,391
2,864 commits
updated Jul 15, 2026
DTCoreText generates NSAttributedString (and SwiftUI AttributedString) from HTML on iOS, macOS, and tvOS. It uses CoreText for layout and rendering, giving you full control over rich text display without a web view.
The project covers two broad areas:
DTAttributedTextView, DTAttributedLabel and related classes for rendering rich textDTCoreText is a Swift package. Add it in Xcode via File > Add Package Dependencies… using:
https://github.com/Cocoanetics/DTCoreText.git
Or in your Package.swift:
.package(url: "https://github.com/Cocoanetics/DTCoreText.git", from: "2.0.0")
Then link the DTCoreText product to your target.
Documentation can be browsed online.
Changelog: GitHub Releases
There is also a Programming Guide with solutions to common problems.
Follow @cocoanetics on Twitter or subscribe to the Cocoanetics Blog for news and updates.
It is open source and covered by a standard 2-clause BSD license. That means you have to mention Cocoanetics as the original author of this code and reproduce the LICENSE text inside your app.
You can purchase a Non-Attribution-License for 75 Euros for not having to include the LICENSE text.
We also accept sponsorship for specific enhancements which you might need. Please contact us via email for inquiries.
322 followers · starred Mar 2018
3,093 followers · starred Jan 2011
989 followers · starred Jan 2011
40 followers · starred Jan 2011
Methods to allow using HTML code with CoreText
Swift
6,391
2,864 commits
updated Jul 15, 2026
DTCoreText generates NSAttributedString (and SwiftUI AttributedString) from HTML on iOS, macOS, and tvOS. It uses CoreText for layout and rendering, giving you full control over rich text display without a web view.
The project covers two broad areas:
DTAttributedTextView, DTAttributedLabel and related classes for rendering rich textDTCoreText is a Swift package. Add it in Xcode via File > Add Package Dependencies… using:
https://github.com/Cocoanetics/DTCoreText.git
Or in your Package.swift:
.package(url: "https://github.com/Cocoanetics/DTCoreText.git", from: "2.0.0")
Then link the DTCoreText product to your target.
Documentation can be browsed online.
Changelog: GitHub Releases
There is also a Programming Guide with solutions to common problems.
Follow @cocoanetics on Twitter or subscribe to the Cocoanetics Blog for news and updates.
It is open source and covered by a standard 2-clause BSD license. That means you have to mention Cocoanetics as the original author of this code and reproduce the LICENSE text inside your app.
You can purchase a Non-Attribution-License for 75 Euros for not having to include the LICENSE text.
We also accept sponsorship for specific enhancements which you might need. Please contact us via email for inquiries.
322 followers · starred Mar 2018
3,093 followers · starred Jan 2011
989 followers · starred Jan 2011
40 followers · starred Jan 2011