在Context上写字没效果

rollrock1987 2015-11-06 09:35:55
- (CGImageRef)imageForPageIndex:(NSUInteger)pageIndex {
if (CGSizeEqualToSize(self.pageSize, CGSizeZero))
return NULL;

CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL,
self.pageSize.width,
self.pageSize.height,
8, /* bits per component*/
self.pageSize.width * 4, /* bytes per row */
colorSpace,
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
CGColorSpaceRelease(colorSpace);
CGContextClipToRect(context, CGRectMake(0, 0, self.pageSize.width, self.pageSize.height));

{//这里是我添加的
CGContextSetLineWidth(context, 1.0);
CGContextSetRGBFillColor (context, 1, 0, 1, 1.0);
UIFont *font = [UIFont boldSystemFontOfSize:11.0];

NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: font, NSFontAttributeName,
nil];

[@"self.text" drawInRect: [UIScreen mainScreen].bounds
withAttributes: dictionary];

}

CGImageRef image = CGBitmapContextCreateImage(context);
CGContextRelease(context);

[UIImage imageWithCGImage:image];
CGImageRelease(image);

return image;
}


其中 有一段代码是我自己添加的(上面已经标注了),我想写几个字在上面,但是为什么没看到任何的文字呢?
...全文
62 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

29,027

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧