我正在开发自定义 PickerView,我在选择器中有两个组件(小时、分钟),我已将分钟组件中的“0”设为灰色且不可选择,除了行被重用外,一切正常。 .. 我的 Minutes 组件以灰色字体显示“0”(这是我想要的),但如果您滚动选择器,我会看到“7、14、21 .....”全部都是灰色字体!!这是我的代码
enter code here
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
if(component == HOURS) {
NSString *s = [self.arrayOfHours objectAtIndex:row];
return [pickerView viewForShadedLabelWithText:s ofSize:20 forComponent:0 rightAlignedAt:52 reusingView:view];
} else if (component == MINUTES) {
NSString *s = [self.arrayOfMinutes objectAtIndex:row];
return [pickerView viewForShadedLabelWithText:s ofSize:20 forComponent:1 rightAlignedAt:52 reusingView:view];
}
else return 0;
}
- (UIView *)viewForShadedLabelWithText:(NSString *)title ofSize:(CGFloat)pointSize forComponent:(NSInteger)component rightAlignedAt:(CGFloat)offset reusingView:(UIView *)view {
//.........................
label = [self shadedLabelWithText:title ofSize:pointSize :component];
//..........................
}
- (UILabel *)shadedLabelWithText:(NSString *)label ofSize:(CGFloat)pointSize :(NSInteger)component
{
UILabel *labelView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
labelView.text = label;
if([label isEqual:@"0"] && component == 1) {
labelView.textColor = [UIColor grayColor];
}
return labelView;
}
1 - 有人可以帮我避免选择器视图重用行吗?
2 - 如何使选择器视图以圆形/圆形显示行?