Last active
June 8, 2021 16:04
-
-
Save aheze/4fc4e08a22981bdd2cd26a4fef74ccb9 to your computer and use it in GitHub Desktop.
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
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