UIPickerView工具栏显示了iPhone 6上的缝隙

时间:2019-02-11 16:29:41

标签: ios swift uipickerview

我在点击文本字段时显示UIPickerView。如何根据手机找到合适的高度?

pickerTypeSelected = 1
self.readTypePicker = UIPickerView.init(frame: CGRect.init(x: 0, y: 0, width: self.navigationController!.view.frame.size.width, height: self.navigationController!.view.frame.size.height / 3.4 ))
self.readTypePicker.delegate = self
self.readTypePicker.dataSource = self
self.readTypePicker.backgroundColor = UIColor.white
textField.inputView = self.readTypePicker

// Toolbar
let toolbar = UIToolbar()
toolbar.barStyle = .default
toolbar.isTranslucent = true
toolbar.tintColor = UIColor.init(red: 71/255, green: 157/255, blue: 250/255, alpha: 1.0)
toolbar.sizeToFit()

// Add button toolbar
// ...

textField.inputAccessoryView = toolbar
isPickerActive = true

在iPhone 6上,使用self.navigationController!.view.frame.size.height / 3.4会在选择器视图之间产生间隙,但在iPhone 7 Plus上可以正常工作。

0 个答案:

没有答案