2017-01-15 1 views
2

Wie animiere ich das TextField, ohne es zu deaktivieren?Wählen Sie UITextField beim Animieren der Hintergrundfarbe

UIView.animate(withDuration: 1.0, delay: 0.0, options: [.repeat, .autoreverse, .curveEaseInOut], animations: { 
        (self.phoneCell.subviews[1].subviews[1] as! UITextField).layer.backgroundColor = UIColor.black.withAlphaComponent(0.2).cgColor 
       }, completion: nil) 

Antwort

1

Um Benutzer-Interaktion für Ihre UITextField während der Animation zu ermöglichen, müssen Sie die Option .allowUserInteraction hinzuzufügen:

UIView.animate(withDuration: 1.0, delay: 0.0, 
    options: [.repeat, .autoreverse, .curveEaseInOut, .allowUserInteraction], 
    animations: { 
     self.myTextField.layer.backgroundColor = UIColor.black.withAlphaComponent(0.2).cgColor 
    }, completion: nil) 
Verwandte Themen