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
CIFilterrequires aCIImage. You can turn aUIViewinto aUIImageand 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.CIImageis bottom left, not top left. Basically the Y axis is flipped.GLKViewto render in - it uses the GPU where aUIImageViewuses the CPU.Let's say you have a
UIViewthat you wish to apply a CIPhotoEffectMono to. The steps to do this would be:UIViewinto aCIImage.CIImageas output.CIContextto create aCGImageand then convert that to aUIImage.Here's a
UIViewextension that will convert the view and all it's subviews into aUIImage:Converting a
UIImageinto aCIImageis one line of code:Here's a function that will apply the filter and return a
UIImage: