在Context上写字没效果
- (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;
}
其中 有一段代码是我自己添加的(上面已经标注了),我想写几个字在上面,但是为什么没看到任何的文字呢?