let alert:UIAlertController = UIAlertController(title: "message",message: "Thank you clicking",preferredStyle: UIAlertControllerStyle.Alert) alert.addAction(UIAlertAction(title: "close AlertView",style: UIAlertActionStyle.Default,handler: nil)) alert.addAction(UIAlertAction(title: "change color",handler:{alertAction in UIView.animateWithDuration(2.5,animations: {self.headerView.backgroundColor = UIColor.brownColor()},completion: {_ in print("animate close") }) })) self.presentViewController(alert,animated:true,completion:nil)