The minimum value of the slider is -1 the maximum value is +1.
@IBAction func changeContrast(_ sender: UISlider) {
DispatchQueue.main.async {
let beginImage = CIImage(image: self.myImageView.image!)
self.filter = CIFilter(name: "CIColorControls")
self.filter?.setValue(beginImage, forKey: kCIInputImageKey)
self.filter.setValue(sender.value, forKey: kCIInputBrightnessKey)
print("Current value of the slider - \(sender.value)")
self.filteredImage = self.filter?.outputImage
self.myImageView.image = UIImage(cgImage: self.context.createCGImage(self.filteredImage!, from: (self.filteredImage?.extent)!)!)
}
}
Also this the printed output od the sliders values.
Current value of the slider - 0.228814
Current value of the slider - 0.271186
Current value of the slider - 0.322034
Current value of the slider - 0.38983
Current value of the slider - 0.45339
Current value of the slider - 0.525424
Current value of the slider - 0.610169
Current value of the slider - 0.682203
Current value of the slider - 0.75
Current value of the slider - 0.79661
Current value of the slider - 0.847458
Current value of the slider - 0.889831
Current value of the slider - 0.915254
Current value of the slider - 0.927966
The reason is that the filter works every time in the result image produced from the previous slider changed value , here because of this line
so you need to reset the imageView's image top of the function by adding this line
//
Also minimum slider value should be 0 and maximum 1