According to Apple docs,
filters property of CALayer
is not supported in iOS
. As i used one of the apps which are applying CIFilter
to UIView
i.e. Splice, Video Editor Videoshow FX for Funimate and artisto. That's means we can apply CIFilter
to UIView
.
I have used SCRecorder
library and try to get this task done by SCPlayer
and SCFilterImageView
. But i am facing black screen issue when video is playing after apply CIFilter
. So kindly help me to complete this task so that i can apply CIFilter
to UIView
and also can change the filter by clicking on a UIButton.
The technically accurate answer is that a
CIFilter
requires aCIImage
. You can turn aUIView
into aUIImage
and then convert that into aCIImage
, but all CoreImage filters that use an image for input (there are some that generate a new image) use a `CIImage for input and output.CIImage
is bottom left, not top left. Basically the Y axis is flipped.GLKView
to render in - it uses the GPU where aUIImageView
uses the CPU.Let's say you have a
UIView
that you wish to apply a CIPhotoEffectMono to. The steps to do this would be:UIView
into aCIImage
.CIImage
as output.CIContext
to create aCGImage
and then convert that to aUIImage
.Here's a
UIView
extension that will convert the view and all it's subviews into aUIImage
:Converting a
UIImage
into aCIImage
is one line of code:Here's a function that will apply the filter and return a
UIImage
: