贴段代码,以备后用。
UIImageView *textImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 568)];
[self.view addSubview:textImageView];
textImageView.backgroundColor = [UIColor blueColor];
UIGraphicsBeginImageContext(textImageView.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 1.0);
CGContextSetRGBStrokeColor(context, 1, 1, 1, 1.0);
CGContextMoveToPoint(context, 0, 100);
CGContextAddLineToPoint(context, 320, 100);
CGContextStrokePath(context);
textImageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();