1

私のコードは以下のようなものですが、その中で、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];

}

4

1 に答える 1

1

フォントを特定のボールド フォントまたは `boldSystemFontOfSize. boldFont を太字にするテキストに渡し、他のフォントを使用して他の文字列を描画します。参考:https ://discussions.apple.com/thread/1533499?start=0&tstart=0

UIFont *boldFont = [UIFont boldSystemFontOfSize:24.0];
UIFont *normalFont = [UIFont systemFontOfSize:24.0];
于 2012-12-05T13:27:01.880 に答える