【发布时间】:2013-08-07 19:18:35
【问题描述】:
以下内容在 iOS 7 中将被视为已弃用: CGContextSelectFont, CGContextShowTextAtPoint。 我应该改用什么?
【问题讨论】:
-
所有 iOS 测试版 API 更改都在保密协议下,不能在这里讨论。这是苹果开发者论坛的东西。
以下内容在 iOS 7 中将被视为已弃用: CGContextSelectFont, CGContextShowTextAtPoint。 我应该改用什么?
【问题讨论】:
你可以使用[yourString drawAtPoint:aPoint withAttributes:dictOfAttributes];
here 的文档。
或者您可以在视图层次结构中添加 UILabel。
【讨论】:
//开始图形上下文 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();
【讨论】: