我能夠改變我的字體顏色,但我也需要改變字體大小,我該怎麼做到這一點?這裏是我的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