Get Updates By E-mail 

Article Written By:
Johann Dowa

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 = UIColor.red // text color
  $0.align = .center // align on center
})

let italic = Style("italic", {
  $0.font = FontAttribute(.CourierNewPS_ItalicMT, size: 25)
  $0.color = UIColor.green
})

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.


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments