- (void)drawRect {
UIGraphicsBeginImageContext(self.view.frame.size);
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(currentContext, 3.0); //or whatever width you want
CGContextSetRGBStrokeColor(currentContext, 0.0, 0.0, 0.0, 1.0);
CGRect myRect = CGContextGetClipBoundingBox(currentContext);
//printf("rect = %f,%f,%f,%f\n", myRect.origin.x, myRect.origin.y, myRect.size.width, myRect.size.height);
CGContextStrokeRect(currentContext, myRect);
UIImage *backgroundImage = (UIImage *)UIGraphicsGetImageFromCurrentImageContext();
UIImageView *myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
[myImageView setImage:backgroundImage];
[self.view addSubview:myImageView];
[backgroundImage release];
UIGraphicsEndImageContext();
}
UIGraphicsBeginImageContext(self.view.frame.size);
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(currentContext, 3.0); //or whatever width you want
CGContextSetRGBStrokeColor(currentContext, 0.0, 0.0, 0.0, 1.0);
CGRect myRect = CGContextGetClipBoundingBox(currentContext);
//printf("rect = %f,%f,%f,%f\n", myRect.origin.x, myRect.origin.y, myRect.size.width, myRect.size.height);
CGContextStrokeRect(currentContext, myRect);
UIImage *backgroundImage = (UIImage *)UIGraphicsGetImageFromCurrentImageContext();
UIImageView *myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
[myImageView setImage:backgroundImage];
[self.view addSubview:myImageView];
[backgroundImage release];
UIGraphicsEndImageContext();
}
No comments:
Post a Comment