I am trying to overlay an image with some extra information: some text and rectangles. Right now I am stuck at drawing the rectangles. They just won't show up. What am I doing wrong? The image itself is being drawn, so the graphics context must be ok.
- (void)drawTag:(NSString *)tag withRect:(CGRect)rect
{
// Set the color in the current graphics context for future draw operations
[[UIColor yellowColor] setStroke];
[[UIColor yellowColor] setFill];
// Create our drawing path
UIBezierPath* drawingPath = [UIBezierPath bezierPathWithRect:rect];
// actually draw it
[drawingPath stroke];
}
- (IBAction)showDetails:(id)sender
{
// draw the image
UIGraphicsBeginImageContext(self.userImage.size);
// This one shows up:
[self.userImage开发者_如何学JAVA drawAtPoint:CGPointZero];
// This one does not:
[self drawTag:@"Test" withRect:CGRectMake(10, 10, 50, 50)];
// Show the whole thing:
self.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
self.imageViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:self.imageViewController animated:YES];
}
You should set the lineWidth
property of UIBezierPath
to a value >= 1
精彩评论