1
icestraw 2014-12-30 11:40:52 +08:00
新建一个 property rowA来保存当前选定的行号,一个property listArray用来保存每一行的View, property array保存数据
然后另外实现这两个方法 - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { UILabel *lbl = [UILabel new]; NSMutableAttributedString *aStr = [[NSMutableAttributedString alloc] initWithString:[_array objectAtIndex:row]]; NSRange range = NSRangeFromString([_array objectAtIndex:row]); [aStr addAttribute:(NSString *)kCTForegroundColorAttributeName value:(id)[UIColor redColor].CGColor range:range]; lbl.attributedText = aStr; if (row == _rowA) { lbl.textColor = [UIColor redColor]; } [_listArray addObject:lbl]; return lbl; } - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { _rowA = row; [_testPicker reloadAllComponents]; } 希望有所帮助 |
3
wisdominessence OP @icestraw 能加我QQ 嘛,我把代码发你看看 叁9柒壹45215, 可以有偿咨询。
|