2010-05-03 29 views

回答

7

您可以實現委託的pickerView:viewForRow:forComponent:reusingView:方法,並從它返回的UILabel實例:

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{ 
    UILabel* label = (UILabel*)view; 
    if (view == nil){ 
     label= [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 190, 44)]; 

     label.textAlignment = UITextAlignmentRight; 
     //Set other properties if you need like font, text color etc 
     ... 
    } 
    label.text = [self textForRow:row forComponent:component]; 
    return label; 
} 
+0

謝謝:)。有效。 – 2010-05-03 07:43:04

+0

非常有幫助,謝謝 – 2013-01-29 07:38:40

+0

我們可以使用這個mentod結合titleForRow:forComponent嗎? – Ans 2014-02-10 08:58:45

相關問題