【问题标题】:Draw a bold type of font in PDF in ios6在ios6的PDF中绘制粗体字体
【发布时间】:2012-12-05 13:08:23
【问题描述】:

我的代码如下所示,但我想使用 BOLD 类型“A/V Calculator”的字体,此字符串以 PDF 格式以普通字体打印,因此任何人都可以提供解决方案以打印该文本大胆的风格。

我的代码如下。

- (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];

}

【问题讨论】:

    标签: iphone objective-c ipad ios6


    【解决方案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];
    

    【讨论】:

      猜你喜欢
      • 2015-01-11
      • 1970-01-01
      • 2011-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多