I'm a big stuck with UITextFields at the moment.
I'm trying to implement a custom appearance for the Text Fields in my app, however they don't seem to work as intended. As an example, I put three text fields on a viewcontroller, each using my CustomTextField class. There is additional logic in my original files to change other aspects of the appearance, but that'll do it:
let bgColor = UIColor.darkGrayColor()
let focusedBgColor = UIColor.whiteColor()
class CustomTextField: UITextField {
override func awakeFromNib() {
super.awakeFromNib()
self.backgroundColor = bgColor
}
override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) {
coordinator.addCoordinatedAnimations({
if self.focused {
self.backgroundColor = focusedBgColor
self.transform = CGAffineTransformMakeScale(1.1, 1.1)
} else {
self.backgroundColor = bgColor
self.transform = CGAffineTransformIdentity
}
}, completion: nil)
}
}
Everything seems to work fine when just switching focus between the text fields.
However, when I actually enter the text fields (show keyboard, enter something (or not)) and go back using the menu button (or the done button), the text field I initially clicked on will change its appearance to something... different. It'll still be in its focused scaling state and the background will become a mix of the "focused" backgroundColor and the "normal" background Color.
I'm confused. Am I doing something wrong or is this actually a bug?