Could you show your present code where you change colour ?
In this tutorial (I did not test yet), they set key images. Could it help ?
https://levelup.gitconnected.com/custom-keyboards-in-ios-affb62668d48
private func buildKey(_ icon: String) -> UIView {
let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false
view.backgroundColor = .clear
let imageView = UIImageView()
view.addSubview(imageView)
imageView.translatesAutoresizingMaskIntoConstraints = false
imageView.widthAnchor.constraint(equalToConstant: 24).isActive = true
imageView.heightAnchor.constraint(equalToConstant: 24).isActive = true
imageView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
imageView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
imageView.contentMode = .scaleAspectFit
imageView.image = .init(systemName: icon, compatibleWith: nil)
imageView.tintColor = .black
return view
}