iphoneuipickerviewfont-size

How to change the Font size in UIPickerView?


I have one UIPickerView. This is having nearly 200 items, each items has long texts, so, i want to resize the UIPickerView's font size. How can i change it? It is possible? Can any one help me? Thanks !

Yuva.M


Solution

  • You need to implement pickerView:viewForRow:forComponent:reusingView: method in picker's delegate

    - (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;
    }