UIPickerView去掉背景上的黑线
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(nullable UIView *)view; { UILabel* pickerLabel = (UILabel*)view; if (!pickerLabel){ pickerLabel = [[UILabel alloc] init]; pickerLabel.font=[UIFont systemFontOfSize:18 weight:1]; pickerLabel.textColor=[UIColor whiteColor]; pickerLabel.textAlignment=1; [pickerLabel setBackgroundColor:[UIColor clearColor]]; } pickerLabel.text=[self pickerView:pickerView titleForRow:row forComponent:component]; //在该代理方法里添加以下两行代码删掉上下的黑线 [[pickerView.subviews objectAtIndex:1] setHidden:TRUE]; [[pickerView.subviews objectAtIndex:2] setHidden:TRUE]; return pickerLabel; }
“人生苦短,不要把时间浪费在犹豫不决上,喜欢的东西就去买,喜欢的人就去追。”