无法通过 NSAttributedString 在 Picker 中更改字体

Cant change fonts in Picker via NSAttributedString

这是我的代码

    self.fontsArray = @[@"Hiragino Kaku Gothic ProN", @"Georgia", @"Times New Roman"];}

-(NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component{
    NSString* str = self.fontsArray objectAtIndex:row];
    UIFont *font = [UIFont fontWithName:str size:13.0];
    NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObject:font
                                    forKey:NSFontAttributeName];
    NSAttributedString* title = [[NSAttributedString alloc]initWithString:str attributes:attrsDictionary];
    return title;
}

我查看了该站点上的解决方案,但无论如何它都不起作用。 会不会是什么错误?

我找到了解决方案。

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
UILabel* tView = (UILabel*)view;
NSString* str = [[CSDMainManager sharedManager].fontsArray objectAtIndex:row];
if (!tView){
    tView = [[UILabel alloc] init];
    UIFont *font = [UIFont fontWithName:str size:20.0];
    tView.font =font;
}
tView.text = [NSString stringWithFormat:@"%@", str];
return tView;

}