Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIPickerView Font

Does anyone know if it is possible to change the font and/or color for individual UIPickerView Items?

like image 695
LilMoke Avatar asked Apr 01 '11 15:04

LilMoke


2 Answers

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
    UILabel* tView = (UILabel*)view;
    if (!tView){
        tView = [[UILabel alloc] init];
            // Setup label properties - frame, font, colors etc
            ...
    }
    // Fill the label text here
    ...
    return tView;
}
like image 100
Sameera Chathuranga Avatar answered Oct 25 '22 07:10

Sameera Chathuranga


Yes, it is possible. To do that you need to implement pickerView:viewForRow:forComponent:reusingView: method in picker's delegate - create UILabel instance there and setup it with whatever attributes you want.

like image 22
Vladimir Avatar answered Oct 25 '22 08:10

Vladimir