我能够改变我的字体颜色,但我也需要改变字体大小,我该怎么做到这一点?这里是我的chaning颜色代码,如何在iOS 7中更改UIPickerView中的文本字体?
- (NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component {
NSString *title = _currencyName[row];
NSAttributedString *attString = [[NSAttributedString alloc] initWithString:title attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
return attString;
}
UPDATE:这并不工作:
NSAttributedString *attString = [[NSAttributedString alloc] initWithString:title attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue-Light" size:40]}];
我尝试过,不工作:NSAttributedString * attString = [[NSAttributedString的alloc] initWithString:标题属性:@ {NSForegroundColorAttributeName:[的UIColor whiteColor] NSFontAttributeName:[UIFont fontWithName:@“HelveticaNeue-Light”size:40]}]; – user3121912
你有什么想法吗? – user3121912
对不起,我的错。 NSFontAttributeName适用于一系列文本。所以你必须添加类似'[attString addAttribute:NSFontAttributeName value:/ *你的字体* /范围:NSMakeRange(0,attString.length)];' – zbMax