如何在不禁用TextField的情况下为TextField设置动画?
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)
答案 0 :(得分:1)
要在动画期间允许用户与UITextField
进行互动,您需要添加选项.allowUserInteraction
:
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)