你应该使用该方法
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
并决定哪一行是突出显示的
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
// i use a UILabel instead of your **custom UIView** , you may add a tick in you custom view
UILabel *testRow = view?(UILabel *)view:[[[UILabel alloc] initWithFrame:CGRectMake(0,0, 140, 40)] autorelease];
testRow.font = [UIFont fontWithName:[testArray objectAtIndex:row] size:16];
testRow.text = [fontsArray objectAtIndex:row];
testRow.backgroundColor = [UIColor clearColor];
if ( row == selectedRow )
{
testRow.backgroundColor = [UIColor greenColor];
}
return testRow;
}
不要忘记将 showSelectionIndicator 设置为 NO
pickView.showsSelectionIndicator = NO;