Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

abcdefg12345

macrumors 6502
Original poster
Jul 10, 2013
281
86
Can someone please help me set content filter on objects such as NSbutton using swift, I'm trying to set content filter false colour but its not putting the colour I want it to use instead its using the default colours.

not sure what im doing wrong

Code:
if let myFilter = CIFilter(name: "CIFalseColor") {
            myFilter.name = "myFilter"
            layer.backgroundFilters = [myFilter]
            layer.setValue(NSColor.black, forKeyPath: "contentFilters.myFilter.inputColor1")
            layer.setValue(NSColor.white, forKeyPath: "contentFilters.myFilter.inputColor2")
            myButton.contentFilters = [myFilter]
        }
 
managed to get it working:
Code:
if let falseColor = CIFilter(name: "CIFalseColor",
                                     withInputParameters:["inputColor0" : color1,
                                                          "inputColor1" : color2
            ]) {
            myButton.contentFilters = [falseColor]
        }
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.