Cant drawing rectangles over image in custom UIView
I have a scene of storyboard with a UIVIewcontroller. Inside this scene i
have a UIImageview that contains the background image, an UIButton, and an
UIView.
This UIView have a overrided drawRect method with:
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
[self setNeedsDisplay];
CGFloat height = self.bounds.size.height;
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextClearRect(context, rect);
CGContextSetFillColorWithColor(context, [UIColor grayColor].CGColor);
CGFloat barWidth = 30;
int count = 0;
NSArray *values = [NSArray arrayWithObjects:@1, @0.5, nil];
for (NSNumber *num in values) {
CGFloat x = count * (barWidth + 10);
CGRect barRect = CGRectMake(x, height - ([num floatValue] *
height), barWidth, [num floatValue] * height);
CGContextAddRect(context, barRect);
count++;
}
CGContextFillPath(context);
}
My question Is: How can i set an image as background of this my custom
UIView and drawing rectangles over it?
Regards
No comments:
Post a Comment