How to change color of selected row in UIPickerView

前端 未结 10 941
孤独总比滥情好
孤独总比滥情好 2020-12-03 10:25

Ok, maybe I\'m missing something really simple and I apologize if that\'s the case, however, I\'ve googled every permutation of the title and have not found! So this is sim

10条回答
  •  难免孤独
    2020-12-03 11:27

    UIPickerView has delegate to set NSAttributeString for title at row and component we can set attribute color like below:

    - (NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component {
        NSDictionary *attrs = @{NSForegroundColorAttributeName : [UIColor redColor]};
        NSString *title = @"title"
        return [[NSAttributedString alloc] initWithString:title attributes:attrs];
    

    }

提交回复
热议问题