有谁知道如何在UIPickerView中设置数组的字体大小。
//Set selectedElement's font to selectedFont
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
ContainerViewController container = (ContainerViewController )[self navigationController].parentViewController;
UITextView selectedText = (UITextView) container.selectedElement;
if(pickerView.tag == 1) {
UIFont selectedFont = [UIFont fontWithName:[availableFonts objectAtIndex:row] size:DEFAULT_FONTSIZE];
[selectedText setFont:selectedFont];
} else {
NSNumber selectedFontSize = [availableFontSizes objectAtIndex:row]
//Set selectedText's font size to selectectedFontSize
}
}
答案 0 :(得分:1)
试试这个:
UIFont *font1 = [UIFont fontNamesForFamilyName:@"Helvetica"];
UIFont *font2 = [UIFont fontNamesForFamilyName:@"HelveticaNeue-Bold"];
UIFont *font3 = [UIFont fontNamesForFamilyName:@"Helvetica Neue"];
self.availableFonts = [NSArray arrayWithObjects:font1, font2, font3, nil];
//Set selectedElement's font to selectedFont
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
ContainerViewController container = (ContainerViewController )[self navigationController].parentViewController;
UITextView selectedText = (UITextView) container.selectedElement;
if(pickerView.tag == 1) {
UIFont selectedFont = [availableFonts objectAtIndex:row];
[selectedText setFont:selectedFont];
} else {
NSNumber selectedFontSize = [availableFontSizes objectAtIndex:row]
//Set selectedText's font size to selectectedFontSize
}
}