How can i customize U开发者_如何学CIDatePicker for Hijri? Like this
In your ViewController
, adopt the UIPickerViewDelegate
protocol, and add a UIPickerView
to the view, setting its delegate and datasource to self
.
Override the pickerView:widthForComponent:
method from UIPickerViewDelegate
to have a custom width for each component (a component is a "column", so here you have three)
Override the numberOfComponentsInPickerView:
from the UIPickerViewDataSource
protocol an return 3
To populate your picker, use pickerView:titleForRow:forComponent:
from UIPickerViewDelegate
and numberOfComponentsInPickerView:
from UIPickerViewDataSource
For a cleaner and more reusable code, I'll just subclass UIPickerView
精彩评论