简体   繁体   English

如何快速去除inputView下的灰色层

[英]How to remove the gray layer under inputView swift

I'm trying to leave the background of my Inputview transparent but I only get it gray.我试图让我的 Inputview 的背景透明,但我只把它变成灰色。

在此处输入图片说明

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.使用inputView ,您必须使用标准键盘的宽度。 However, you can set an empty view as the inputView , and set your custom keyboard as the inputAccessoryView instead.但是,您可以将一个空视图设置为inputView ,并将您的自定义键盘设置为inputAccessoryView 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

尝试像InputViewCollection?.alpha = 0.0一样设置背景视图的 alpha 值

inputViewController s and inputView s seem to have this gray background. inputViewController s 和inputView s 似乎有这种灰色背景。 However if you use inputAccessoryViewController or inputAccessoryView , then the background is clear.但是,如果您使用inputAccessoryViewControllerinputAccessoryView ,则背景是清晰的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM