Last active
December 18, 2015 17:54
-
-
Save joelbrewer/94c1eed7d872d765a93c to your computer and use it in GitHub Desktop.
attributedTitleForRow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component { | |
NSString *title = [[self.items objectAtIndex:row] objectForKey:@"text"]; | |
NSString *color = [[self.items objectAtIndex:row] objectForKey:@"color"]; | |
NSAttributedString *attrStr; | |
if ([ color isEqualToString:@"green"]) { | |
attrStr = [[NSAttributedString alloc] initWithString:title attributes:@{ NSForegroundColorAttributeName : [UIColor greenColor] }]; | |
} else { | |
attrStr = [[NSAttributedString alloc] initWithString:title attributes:@{ NSForegroundColorAttributeName : [UIColor blackColor] }]; | |
} | |
return attrStr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment