Featured Development Resources iOS Development Libraries Open Source iOS Libraries And Tools Swift

SwiftRichString – A Swift Library That Simplifies Styling Attributed Strings

SwiftRichString is an open source library submitted by Daniele Margutti that simplifies working with attributed strings.

With SwiftRichString you can style attributed strings using a clear type-safe syntax, combine attributed and non-attributed strings, and more.

This snippet from the readme shows how one could create styles, and apply them to an attributed string with SwiftRichString:

// Define your own used styles
let bold = Style(“bold”, {
$0.font = FontAttribute(.CourierNewPS_BoldItalicMT, size: 30) // font + size
$0.color = // text color
$0.align = .center // align on center

let italic = Style(“italic”, {
$0.font = FontAttribute(.CourierNewPS_ItalicMT, size: 25)
$0.color =

let attributedString = (“Hello ” + userName).set(style: bold) + “\nwelcome here”.set(style: italic)

You can find SwiftRichString on Github here.

A great library for working with attributed strings.