iOS10的UIPickerView分割線顏色,文字顏色
遵循代理,然後實現下面的代理方法即可:
pickerView.delegate = self;
pickerView.dataSource = self;
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView*)pickerView
{
return1;
}
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
{
return40;
}
- (NSInteger
{
returnself.genderArray.count;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow: (NSInteger)row inComponent:(NSInteger)component
{
_genderStr = [NSStringstringWithFormat:@"%@",self.genderArray[row]];
}
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
//設定分割線的顏色
for(UIView *singleLine in pickerView.subviews)
{
if (singleLine.frame.size.height < 1)
{
singleLine.
}
}
//設定文字的屬性
UILabel *genderLabel = [UILabelnew];
genderLabel.textAlignment = NSTextAlignmentCenter;
genderLabel.text = self.genderArray[row];//self.genderArray裡邊內容為@[@"男",@"女"]
genderLabel.textColor = kSpecialTextColor;
return genderLabel;
}