【问题标题】:CGContextShowTextAtPoint deprecated - what shall I use now?不推荐使用 CGContextShowTextAtPoint - 我现在应该使用什么?
【发布时间】:2013-08-07 19:18:35
【问题描述】:

以下内容在 iOS 7 中将被视为已弃用: CGContextSelectFont, CGContextShowTextAtPoint。 我应该改用什么?

【问题讨论】:

  • 所有 iOS 测试版 API 更改都在保密协议下,不能在这里讨论。这是苹果开发者论坛的东西。

标签: iphone ios ios7 xcode5


【解决方案1】:

你可以使用[yourString drawAtPoint:aPoint withAttributes:dictOfAttributes];

here 的文档。

或者您可以在视图层次结构中添加 UILabel

【讨论】:

    【解决方案2】:

    //开始图形上下文 UIGraphicsBeginImageContext(imageSize);

    //get the context for coreGraphics
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    
    CGContextSetTextDrawingMode(ctx, kCGTextFill);
    [[UIColor blackColor] setFill];
    [@"yourstring" drawAtPoint:CGPointMake(0, 0) withAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"Helvetica"  size:17]}];
    //make image out of bitmap context
    UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-18
      • 2016-06-26
      • 2013-05-20
      • 1970-01-01
      • 2012-01-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多