Post

Replies

Boosts

Views

Activity

Attributed String / Text in SwiftUI
Currently using Attributed String in Foundation we could have several text stylings in a long string by using something like this: attributedSentence.setAttributes(redTextAttributes, range: NSRange(location: 0, length: 3)) How do we achieve this in SwiftUI? Yes we can concat string like this Text("Hi there").foregroundColor(.red) + Text("how are you"?).foregroundColor(.blue) But this static approach is not possible if we apply localisation in our app. Each language have different grammar which leads to different word structure. How could we have a consistent "Hi there" in red color regardless of it's language?
2
0
2.2k
Jul ’20