Для цели c
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
UILabel* pickerLabel = (UILabel*)view;
if (!pickerLabel){
pickerLabel = [[UILabel alloc] init];
// Setup label properties - frame, font, colors etc
[pickerLabel setFont:[UIFont fontWithName:LATO_REGULAR_FONT size:SIZE_SEMIBOLD_FONT]];
pickerLabel.textColor = primaryTextColor;
pickerLabel.textAlignment = NSTextAlignmentCenter;
}
// Fill the label text here
pickerLabel.text = self.dataSourceArray[row];
return pickerLabel;
}
Для Swift 2.3
func pickerView(pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusingView view: UIView?) -> UIView{
var label = view as! UILabel!
if label == nil {
label = UILabel()
}
label.font = LATO_REGULAR_FONT_17
label.text = dataArray[row] as? String
label.textAlignment = .Center
return label
}