UIGraphicsBeginImageContext(self.view.frame.size);
CGContextRef gc = UIGraphicsGetCurrentContext();
[[UIColor lightGrayColor] setFill];
CGContextTranslateCTM(gc, CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds));
for (int i = 0 ; i < 12; i++) {
CGContextAddRect(gc, CGRectMake(-5, 50, 10, 50));
CGContextFillPath(gc);
CGContextRotateCTM(gc, 30 * M_PI / 180);
}
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageView *imageView = [[[UIImageView alloc] initWithImage:image] autorelease];
对应效果图:
未完待续...