Created
April 13, 2018 16:01
-
-
Save joltguy/d7f8ea304c30c492c2257f9c9f7acba3 to your computer and use it in GitHub Desktop.
Swift String extension for Unicode strikethrough text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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