CALayer.filters on iOS 9

Does CALayer.filters finally do anything on iOS 9? I hoped this might finally be implemented, given that OS X and iOS now share a common implemention of Core Image. However, CIFilter.name is read-only (did it used to be?), so it's impossible to name the filter in order to use the CALayer.setValue (foo, forKeyPath: "filters.myFilter.param") technique that you'd use on OS X to set the filter's parameters.


Just setting the inputScale directly on a CIPixellate filter that's been added to a layer's filters array seems to do nothing (see sample code below).


So, I guess we're waiting for iOS 10?


—invalidname


import UIKit
class ViewController: UIViewController {
    @IBOutlet weak var textField: UITextField!
    @IBOutlet weak var pixellationSlider: UISlider!
    let pixellationFilter : CIFilter! = CIFilter(name: "CIPixellate")
   
    override func viewDidLoad() {
        super.viewDidLoad()
        /
        pixellationFilter.setDefaults()
        textField.layer.filters = [pixellationFilter]
        updatePixellationFilterScale()
        NSLog ("textField.layer.filters: \(textField.layer.filters)")
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        /
    }
    func updatePixellationFilterScale() {
        NSLog ("slider is \(pixellationSlider.value)")
        pixellationFilter.setValue(NSNumber(float: pixellationSlider.value), forKey: kCIInputScaleKey)
    }
   
   
    @IBAction func pixellationValueSliderChanged(sender: AnyObject) {
        updatePixellationFilterScale()
    }
}

Interesting note: if you use the view debugger in Xcode, the view will appear filtered as expected.

CALayer.filters on iOS 9
 
 
Q