私のコードは以下のようなものですが、その中で、BOLDタイプの「A / VCalculator」のフォントを使用したいので、この文字列は通常のフォントでPDFで印刷されるため、誰でもこの解決策を提供して、そのテキストをBOLDスタイルで印刷できます。
私のコードを以下に示します。
- (void) drawHeader
{
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(currentContext, 0.0, 0.0, 0.0, 1.0);
NSString *textToDraw = @"A/V Calculator";
UIFont *font = [UIFont systemFontOfSize:24.0];
CGSize stringSize = [textToDraw sizeWithFont:font constrainedToSize:CGSizeMake(pageSize.width - 2*kBorderInset-2*kMarginInset, pageSize.height - 2*kBorderInset - 2*kMarginInset) lineBreakMode:UILineBreakModeWordWrap];
CGRect renderingRect = CGRectMake(kBorderInset + kMarginInset, kBorderInset + kMarginInset, pageSize.width - 2*kBorderInset - 2*kMarginInset, stringSize.height);
[textToDraw drawInRect:renderingRect withFont:font lineBreakMode:UILineBreakModeWordWrap alignment:UITextAlignmentLeft];
}