IOS7 UIPickerView how to hide the selection indicator

Viewed 23689

How can I hide those 2 lines on the selected row?

enter image description here

16 Answers
func numberOfComponents(in pickerView: UIPickerView) -> Int
    {
        pickerView.subviews.forEach({
            $0.isHidden = $0.frame.height < 1.0
        })
        return 1
    }

Swift 4.2

Paste both lines of code into either your titleForRow or viewForRow delegate method of the pickerView.

pickerView.subviews[1].isHidden = true
pickerView.subviews[2].isHidden = true

And you should be good to go.

Swift 5

func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) ->  String? {
        pickerView.subviews[1].isHidden = true
        pickerView.subviews[2].isHidden = true
        return pickerData[row]
}

enter image description here

Related