Im trying to create a class that adds blur effect to images passed into it when initialized but am getting an error to pass in the image view. I'm using Xcode 7.3, Swift 2.2; here is my code, please take a look.
This is my class
class addBlurEffect: UIViewController {
private var newBlurEffect = UIVisualEffectView(effect: UIBlurEffect(style: .Light))
private var objectToBlur = UIImageView()
convenience init(objToBlur: AnyObject) {
self.init()
objectToBlur = objToBlur as! UIImageView
blur()
}
func blur() {
newBlurEffect.frame = objectToBlur.bounds
objectToBlur.addSubview(newBlurEffect)
}
}
This is my code in the ViewController.swift file
@IBOutlet weak var blurHeader: UIImageView!
var addBlur = addBlurEffect(_: blurHeader)
But I get this error "Instance member 'blurHeader' cannot be used on type 'ViewController'" instance error
Any help is greatly appreciated in pointing me to a possible solution. Thanks.
Oh, I also tried the following with the same results:
convenience init(objToBlur: UIImageView) {
self.init()
objectToBlur = objToBlur
blur()
}