Search code examples
swiftuimetalcore-imagemetalkit

SwiftUI/Metal Text Render using CITextImageGenerator - change color


I have written code to render text to a MTKView, but I have not found a way to modify the color of the text. Has anyone had success with this or can someone more familiar with CoreImage assist? Thank you.

let image = CIFilter(name: "CITextImageGenerator", parameters: [
                "inputText": "Hello, World",
                            "inputFontName": "HelveticaNeue",
                            "inputFontSize": 12,
                            "inputScaleFactor": 2.0])?.outputImage!
                                


Solution

  • Pass an attributed string instead of string to a CIAttributedTextImageGeneratorFilter instance.