Quantcast
Channel: Controls – TAGTECINFO
Viewing all articles
Browse latest Browse all 336

[iOS App Dev Libraries, Controls, Tutorials, Examples and Tools]SwiftRichString – A Swift Library That Simplifies Styling Attributed Strings

$
0
0

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.

Original article: SwiftRichString – A Swift Library That Simplifies Styling Attributed Strings

©2017 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.

Reference source: iOS App Dev Libraries, Controls, Tutorials, Examples and Tools


Viewing all articles
Browse latest Browse all 336

Trending Articles