I'm trying to do the following in my app: I made a file named "blur.swift", this file has code to blur the up side of a view so that everything that passes there gets "blurred". I have made this file the class to one view in Interface Builder. It worked perfectly, except for one detail: I cannot put a button via IB in the sae region that receives the blur, because the button also gets blurred and does not work, and I need to insert this button there because that is the button the user will press to return to the previous screen… so I decided to insert the button programmatically in the same file that has the code with the blur effect, now it worked! The blur is there and the button too!
The problem that I cannot solve is how to make this button actually works, I tried using "performSegueWithIdentifier" but I'm certain I'm missing something here, because it simple does not work! So I decided to ask for help here, below is the entire code from my "blur.swift" file.
Just to make things more clear: the segue with identifier "back" goes from the view that has the "blur.swift" class to the view controller (named giraanam) that I want to open when the user press the button.
@IBDesignable
class blur: UIView {
override func layoutSubviews() {
super.layoutSubviews()
// Insert blur effect
var blur:UIBlurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light)
var effectView:UIVisualEffectView = UIVisualEffectView (effect: blur)
effectView.frame = CGRectMake(0,0,320,69)
self.addSubview(effectView)
///Insert the button
let button = UIButton.buttonWithType(UIButtonType.System) as UIButton
button.frame = CGRectMake(20, 25, 34, 34)
button.setBackgroundImage(UIImage(named:"Back_Resultados.png"),forState: UIControlState.Normal)
button.performSegueWithIdentifier("back", sender: self)
self.addSubview(button)
}
}
Thanks to you all!