UIPickerView — Fixed Labels

Luis Machado
1 min readFeb 13, 2017

--

I often need to add labels inside my picker views in order to specify the units of each column.

iOS timer app as an example of the labels

However, I didn’t found any suitable solution online so I decided to extend UIPickerView and create my own method.

You can find it on GitHub.

The method receives a [Int:UILabel] dictionary where the Int reflects the column where the respective UILabel should be applied to. That way you can easily add labels to only some columns.

The second parameter, the UIView, is the view in which the picker will be/is added. This is needed to best calculate the position of each label.

Suggestions or questions? Feel free to comment :)

--

--