attributedTextImageGenerator()
Generates an attributed-text image.
Declaration
class func attributedTextImageGenerator() -> any CIFilter & CIAttributedTextImageGeneratorReturn Value
The generated image.
Discussion
This method generates an attributed-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 attributed-text image generator filter uses the following properties:
textscaleFactorA
floatrepresenting the scale of the font to use for the generated text.- padding
A
floatrepresenting the value for an additional number of pixels to pad around the text’s bounding box.
The following code creates a filter that generates an attributed-text image:
func attributedTextImage() -> CIImage {
let attributedTextImageFilter = CIFilter.attributedTextImageGenerator()
attributedTextImageFilter.text = NSAttributedString(string: "Hello world! 👋")
attributedTextImageFilter.scaleFactor = 10
attributedTextImageFilter.padding = 5
return attributedTextImageFilter.outputImage!
}[Image]
See Also
Filters
aztecCodeGenerator()barcodeGenerator()blurredRectangleGenerator()checkerboardGenerator()code128BarcodeGenerator()lenticularHaloGenerator()meshGenerator()pdf417BarcodeGenerator()qrCodeGenerator()randomGenerator()roundedRectangleGenerator()roundedRectangleStrokeGenerator()starShineGenerator()stripesGenerator()sunbeamsGenerator()