你应该打电话
processSubviewsNight(of: subview)
在其他条件下。否则,textfield的子视图将传递给此方法。
func processSubviewsNight(of view: UIView) {
for view in self.view.subviews {
if let lbl = view as? UILabel {
label.textColor = UIColor.white
} else if let textField = view as? UITextField {
textField.setValue(UIColor.white, forKeyPath: "_placeholderLabel.textColor")
textField.backgroundColor = UIColor.appBlueColor()
} else if let button = view as? UIButton {
button.backgroundColor = UIColor.red
} else{
processSubviewsNight(of: view)
}
}
}