如何更改UIPickerView中的字体大小?

Sam*_*nga 3 iphone uipickerview

可能重复:
UIPickerView字体...

我真的在我的应用程序中遇到了这个问题.我到处搜索都无济于事.如何更改UIPickerView中的字体大小?

Vla*_*mir 15

viewForRow:forComponent:在picker的数据委托中实现方法,用你需要的字体(以及所有其他属性)在其中创建UILabel实例,例如:

- (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;
}
Run Code Online (Sandbox Code Playgroud)