Getting the UIKeyboard background color programmatically

You could do something like this:

UIKeyboardAppearance currentAppearance = yourTextView.keyboardAppearance;
if (currentAppearance == UIKeyboardAppearanceDark) {
    // dark
}
else if (currentAppearance == UIKeyboardAppearanceDefault) {
    // default
}
else if (currentAppearance == UIKeyboardAppearanceLight) {
    // light
}

Swift 5

You can use an input view and it matches the keyboard style.

let textView = UITextView()
let frame = CGRect(x: 0, y: 0, width: 0, height: 40)
textView.inputAccessoryView = UIInputView(frame: frame, inputViewStyle: .keyboard)

I suggest you to get your keyboard color's RGB from DigitalColor Meter as we use this tool in Mac or you can get it by any other tool.

And then simply assign these RGB value to your accessory view and match its color with your keyboard.

The RGB value of your keyboard is seems to me is like (63,63,63) and you can use this:

[UIColor colorWithRed:63/255.0 green:63/255.0 blue:63/255.0 alpha:1]

Hopefully it will helps you.