textImageGenerator()
Generates a text image.
Declaration
class func textImageGenerator() -> any CIFilter & CITextImageGeneratorReturn Value
The generated image.
Discussion
This method generates a text image. The effect takes the input string property and the scale factor to scale up the text. You commonly combine this filter with other filters to create a watermark on images.
The text image generator filter uses the following properties:
textThe
stringto render. The string can contain non-ASCII characters.fontNameA
stringrepresenting the name of the font to be used to generate the image.fontSizeA
floatrepresenting the size of the font as an NSNumber.scaleFactorA
floatrepresenting the scale of the font for the generated text as an NSNumber.
The following code creates a filter that generates a string of text as a grayscale image:
func textImage(inputText: String) -> CIImage {
let textImageGenerator = CIFilter.textImageGenerator()
textImageGenerator.text = inputText
textImageGenerator.fontName = "Helvetica"
textImageGenerator.fontSize = 25
textImageGenerator.scaleFactor = 4
return textImageGenerator.outputImage!
}[Image]
See Also
Filters
attributedTextImageGenerator()aztecCodeGenerator()barcodeGenerator()blurredRectangleGenerator()checkerboardGenerator()code128BarcodeGenerator()lenticularHaloGenerator()meshGenerator()pdf417BarcodeGenerator()qrCodeGenerator()randomGenerator()roundedRectangleGenerator()roundedRectangleStrokeGenerator()starShineGenerator()stripesGenerator()