I'm working on an app that overlays text onto an image. We want to be able to constrain the width of the text and have it break onto multiple lines, much in the same way that UILabel does when we set numberOfLines = 0. In my mind, this should be possible by constraining the extent that the filter has to work within somehow, or by chaining it with a clamp (since the output bitmap is generated lazily.) Unfortunately, nothing I've run into seems to do the trick:
- The
CIClampapproach generates a nil outputImage when provided aCIVector(cgRect:)argument - There doesn't seem to be a way to specify a
CIFilterShapeto draw the text within when using the bundled filters - You can provide a
CIFilterShapewhen invokingCIKernel.applybut a) I don't have a custom CIKernel (and am hoping not to write one) and b) I don't have a way to extract the kernel from theCIAttributedTextGeneratorfilter
I'm resigning myself to manually computing line breaks but it really seems like Core Image ought to be able to handle this use case. Am I just missing something?