不说废话,直接上代码
//显示数据
-(void)fun_show_data
{
UIGraphicsBeginImageContext(_img_show_data.frame.size);
CGContextRef ref = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(ref, 5);
CGContextSetAllowsAntialiasing(ref, YES);
CGContextSetRGBStrokeColor(ref, 1.0, 0.0, 0.0, 1.0);
CGContextBeginPath(ref);
CGContextMoveToPoint(ref, 0, img_rect.size.height/2);
CGContextAddLineToPoint(ref, img_rect.size.width, img_rect.size.height/2);
CGContextStrokePath(ref);
NSString *str = @"你好!";
[str drawInRect:CGRectMake(50, 50, 100, 100) withAttributes:nil];
CGContextStrokeRect(ref, CGRectMake(0, 0, img_rect.size.width, img_rect.size.height));
_img_show_data.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}