ios - how to enable filter for Image in swift 3? -
i have image view contains image , want add filter image used codes filter , put new image instead of old image here code:
let filternames = cifilter.filternames(incategories: nil) @iboutlet weak var myimage: uiimageview! @ibaction func filter1(_ sender: any) { func simpleblurfilterexample(myimage: uiimage) -> uiimage { // convert uiimage ciimage let inputciimage = ciimage(image: myimage)! // create blur cifilter, , set input image let blurfilter = cifilter(name: "cigaussianblur")! blurfilter.setvalue(inputciimage, forkey: kciinputimagekey) blurfilter.setvalue(8, forkey: kciinputradiuskey) // filtered output image , return let myimage = blurfilter.outputimage! return uiimage(ciimage: myimage) } }
as see here have outlet image named image , want input image image , after pushing button change image output image filter
you need set image in uiimageview
myimage.image = filter1(myimage: myimage.image)
maybe should call imageview myimageview reduce confusion well
Comments
Post a Comment