你應該使用方法
- (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;
}
不要忘記showsSelectionIndicator設置爲NO
pickView.showsSelectionIndicator = NO;
我想我不是在討論UIPickerView的多選行爲;如果你提到的庫可以創建一個具有所需設計的選擇器,那麼從那裏發佈一些示例代碼; – Ans 2012-04-19 05:41:47
您從該庫的左上角的該鏈接下載了該zip文件可用的代碼。 – 2012-04-19 06:13:17