I'm trying to leave the background of my Inputview transparent but I only get it gray.
The code is:
let fakeField : UITextField = UITextField(frame: CGRect.zero)
//1
InputViewCollection = InputView(frame: CGRect(x: 0, y: 0, width: 0, height: 216)) //Intialize custom input view
InputViewCollection?.delegate = self //delegate
InputViewCollection?.dataSource = self //datasource
//2
InputViewCollection?.backgroundColor = UIColor.clear
self.fakeField.inputView = InputViewCollection //Assign input view
self.fakeField.keyboardAppearance = .default
self.view.addSubview(self.fakeField)
How can I leave transparent background of a inputview?
Thanks
When using inputView
, you have to use the width of the standard keyboard. However, you can set an empty view as the inputView
, and set your custom keyboard as the inputAccessoryView
instead. This doesn't have a grey background. The solution would be:
self.fakeField.inputView = UIView() // Set an empty, zero-sized view as inputView, in order to remove the standard keyboard
self.fakeField.inputAccessoryView = InputViewCollection // Set your custom keyboard this way instead