Open alelordelo opened 4 months ago
also tried this, but didn't work...
RichTextEditor(text: richText, context: context, config: editorConfig) { _ in
context.setAttributedString(to: cell.richText)
context.colors[.foreground] = .purple
}
Hi @alelordelo - the string needs to be observed in some way for the change to update the UI. You can then use the setColor
function in the RichTextContext
to update any color.
Hi @alelordelo - the string needs to be observed in some way for the change to update the UI. You can then use the
setColor
function in theRichTextContext
to update any color.
thanks @danielsaidi
But isn't that what I am doing here? Or maybe I missed something?
RichTextEditor(text: richText, context: context, config: editorConfig) { _ in
context.setAttributedString(to: cell.richText)
context.setColor(.purple, for: .foreground)
}
I created a func to set colors from RichTextContext:
And then I init like this:
Prints: Setting color sRGB IEC61966-2.1 colorspace 0.5 0 0.5 1 for key foreground
But it does not get applied...
Is this correct? Or is there a better way to set a color from the context ?