'sliders slow down and don't move smoothly

I'm doing an application "Photo Editor". I'm beginner in swift. I have a problem with my sliders. They don't work as I need. May be someone know, how I can resolve this problem?

Sliders don't work correctly and I need help with it. I don't know, why it's work like that.

import UIKit

class ViewControllerFilters: UIViewController {

@IBOutlet weak var imageView: UIImageView!
var image: UIImage? = nil
var filter = CIFilter(name: "CISepiaTone")
var filteredImage: CIImage? = nil


@IBOutlet weak var slider: UISlider!
let context = CIContext()

@IBOutlet weak var slider2: UISlider!
@IBOutlet weak var slider3: UISlider!

@IBOutlet weak var slider4: UISlider!

override func viewDidLoad() {
    super.viewDidLoad()


    self.imageView.image = image
    self.slider.addTarget(self, action: #selector(sliderValueDidChange(sender:)), for: .valueChanged )
    self.slider2.addTarget(self, action: #selector(sliderValueDidChange(sender:)), for: .valueChanged)
    self.slider3.addTarget(self, action: #selector(sliderValueDidChange(sender:)), for: .valueChanged)
    self.slider4.addTarget(self, action: #selector(sliderValueDidChange(sender:)), for: .valueChanged)


}


let colorControlsFilter = CIFilter(name: "CIColorControls")!
let sepiaFilter = CIFilter(name:"CISepiaTone")!
let sharp = CIFilter(name: "CISharpenLuminance")!




@objc func sliderValueDidChange(sender: UISlider!) {
    switch sender.tag {
    case 0:
        let value = sender.value
        self.sharp.setValue(value, forKey: kCIInputSharpnessKey)
    case 1:
        let value = sender.value
        self.colorControlsFilter.setValue(value, forKey: kCIInputBrightnessKey)
    case 2:
        let value = sender.value
        self.colorControlsFilter.setValue(value, forKey: kCIInputContrastKey)
    case 3:
        let value = sender.value
        self.colorControlsFilter.setValue(value, forKey: kCIInputSaturationKey)
    default:
        print("no such elements")
    }

    self.updateImage()
}

func updateImage() {
    let originalCIImage = CIImage(image: self.image!)
    self.colorControlsFilter.setValue(originalCIImage, forKey: kCIInputImageKey)

    self.sharp.setValue(self.colorControlsFilter.outputImage, forKey: kCIInputImageKey)
    self.imageView.image = UIImage(ciImage: self.sharp.outputImage!)

}

I need a smoothly moving of my sliders, because it's impossible to work with it.



Solution 1:[1]

you will receive valueChanged event only when the user stops moving the slider.

slider.isContinuous = false

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ayush Singh