When I run my custom keyboard, it's always being styled with my dark style. If I use they keyboard in Safari for example, this code returns yellow when it should be red. If I then pull down Spotlight it still returns yellow. What am I doing wrong here?
override func textDidChange(textInput: UITextInput) {
self.nextKeyboardButton.backgroundColor = myColor
}
var myColor: UIColor {
get {
var proxy = textDocumentProxy as UITextDocumentProxy
if proxy.keyboardAppearance == UIKeyboardAppearance.Light {
return UIColor.redColor()
} else {
return UIColor.yellowColor()
}
}
}
The problem is proxy.keyboardAppearance
won't always return .Light
even if it is the light keyboard - it may return .Default
. To solve the problem, I changed the conditional to check for .Dark
else return a color appropriate for the light keyboard.