Skip to content

Instantly share code, notes, and snippets.

@joltguy
Created April 13, 2018 16:01
Show Gist options
  • Save joltguy/d7f8ea304c30c492c2257f9c9f7acba3 to your computer and use it in GitHub Desktop.
Save joltguy/d7f8ea304c30c492c2257f9c9f7acba3 to your computer and use it in GitHub Desktop.
Swift String extension for Unicode strikethrough text
extension String {
func strikeThrough() -> String {
var struck = ""
let strikeChar: Character = "\u{0336}"
self.forEach { (char) in
var xchar = UnicodeScalarView(char.unicodeScalars)
xchar.append(strikeChar.unicodeScalars.first!)
struck.append(String(xchar))
}
return struck
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment