Reputation: 245
quick question, I got this drawRect
method in the a UIView
with a UILabel
and circle.The circle is drawn correctly but the UILabel
is not.
Any ideas?
Thanks your help.
- (void)drawRect:(CGRect)theRect{
CGRect rect = self.bounds;
//text label
UILabel * pText = [[UILabel alloc] initWithFrame: rect];
pText.text = @"demo";
// Circle
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:rect];
rect = CGRectInset(rect, 5, 5);
[path appendPath:[UIBezierPath bezierPathWithOvalInRect:rect]];
path.usesEvenOddFillRule = YES;
[self.color set];
[path fill];
}
Upvotes: 1
Views: 3500
Reputation: 145
You need to call :
[super drawRect:rect];
in order to draw your uilabel before drawing the circle.
Upvotes: 0
Reputation: 495
You need to add your UILabel to your view.
//text label
UILabel * pText = [[UILabel alloc] initWithFrame: rect];
pText.text = @"demo";
[self addSubview:pText];
[pText release];
Upvotes: 1