I'm trying to animate an UIButton once two textsfields have had text entered. The button animates even if there is no text entered. I thought maybe it was an issue with there being placeholder text, but that has no effect. I have tried != "" as well as != nil
Here's my code
override func viewDidLoad() {
super.viewDidLoad()
self.title = ""
textFieldConfig()
loginButtonConfig("LOG IN")
}
func loginButtonConfig(title:String) {
let frameWidth = self.view.frame.width
let frameHeight = self.view.frame.height
var button = UIButton()
button.frame = CGRect(x: 0, y: 300, width: 0, height: 50)
button.bounds = CGRect(x: 0, y: 0, width: 0, height: 50)
button.backgroundColor = UIColor(red: 24.0/255.0, green: 198.0/255.0, blue: 152.0/255.0, alpha: 1.0)
button.setTitle(title, forState: .Normal)
button.titleLabel?.textAlignment = NSTextAlignment.Center
self.view.addSubview(button)
//WHY ISN'T THE IF STATEMENT WORKING AS IT SHOULD???
if self.userTextField.text != nil && self.passwordTextField.text != nil {
UIView.animateWithDuration(1.0, animations: { () -> Void in
button.frame = CGRect(x: 0, y: 300, width: frameWidth, height: 50)
button.bounds = CGRect(x: 0, y: 0, width: frameWidth, height: 50)
})
}
}
Any help would be appreciated. Thanks :)
Aucun commentaire:
Enregistrer un commentaire