Hello Everyone,
Today I am going show you how to remove
selection indicator lines from UIPickerView . This is very simple. Before we start on the
process to remove indicator lines, let’s understand the hierarchy of views layer
in UIPickerView.
UIPickerView
contains subviews to draw two indicator lines to display the current selection.
Step
1: I am
assuming that you have UIPickerView setup already done. And currently displays
like below screenshot.
Step
2: Magic
begins here.
Ø
Add
viewDidLayoutSubviews
method on current view controller.
Ø
After that add below code into that method.
for i in [1, 2] {
optionsPickerView.subviews[i].isHidden = true
}
Step
3: At last viewDidLayoutSubviews method will be like below.
override func viewDidLayoutSubviews()
{
super.viewDidLayoutSubviews()
for i in [1, 2] {
optionsPickerView.subviews[i].isHidden = true
}
}
Step
4: Relaunch
application with above changes applied to the view controller and UIPickerView
will not display indicator lines.
Output
will be like below screenshot.
Happy
Coding!! Thank You!!