1

I have created a button called runButton, and I want some labels to get unhidden, and I also want a visual effect with blur to appear. The visual effect with blur has a width and height of 0 in the viewDidLoad function. I want the animation to expand it's size to fill the entire screen and blur it. The I want the hidden labels to get unhidden. But, I have to double click the button to execute the animation. Here is my runButton code:

 @IBAction func runButton(sender: AnyObject) {
    outputLabel.hidden = false
    var name = textFieldText.text
    outputLabel.text = "  Console output: Hello \(name)!"
    xButton.hidden = false

    UIView.animateWithDuration(0.5, animations: {
        self.visualEffectView.frame = CGRect(x: 0, y: 0, width: 320, height: 568)

    })

}

What happens is that the animation executes only when I click the button twice. I want it to happen with one click.

Krish Wadhwana
  • 1,544
  • 2
  • 12
  • 24

1 Answers1

0

Please check below in your code, forControlEvents: UIControlEvents.TouchUpInside -

button.addTarget(self, action: "runButton:", forControlEvents: UIControlEvents.TouchUpInside)
Santu C
  • 2,644
  • 2
  • 12
  • 20