How to Change Color selected Picked value from pickerview?

妖精的绣舞 提交于 2019-12-03 17:34:51
Akshay

This is incorrect. You should reload the selected component. Then you need to fetch the selected row and update its color in viewForRow:forComponent:. Something like-

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {

        //On Selecting the component row
        if (component == 0) {

        } else if (component == 1) {

            [quantityPickerDelegate didChangeLabelText:[pickerArray objectAtIndex:row]];// delegate passing the selected value
            [pickerView reloadComponent:component]; //This will cause your viewForComp to hit
        }
    }

- (UIView *)viewForRow:(NSInteger)row forComponent:(NSInteger)component
{
     //...
     //Your usual code
      pickerLabel.textColor = defaultColor;

     if([self.pickerView selectedRowInComponent:component] == row) //this is the selected one, change its color
     {
            pickerLabel.textColor = [UIColor colorWithRed:0.0745 green:0.357 blue:1.0 alpha:1];
     } 
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!