Skip to content

Instantly share code, notes, and snippets.

@aheze
Last active June 8, 2021 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aheze/4fc4e08a22981bdd2cd26a4fef74ccb9 to your computer and use it in GitHub Desktop.
Save aheze/4fc4e08a22981bdd2cd26a4fef74ccb9 to your computer and use it in GitHub Desktop.
struct ContentView: View {
var body: some View {
Text(makeAttributedString())
}
func makeAttributedString() -> AttributedString {
var string = AttributedString("Some Attributed String")
string.foregroundColor = .blue
if let range = string.range(of: "Attributed") { /// here!
string[range].foregroundColor = .red
}
return string
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment