drawRect中的UILabel不绘制
快速问题,我在带有 UILabel
和圆的 UIView
中得到了这个 drawRect
方法。圆绘制正确,但 UILabel
不是。
有什么想法吗?
谢谢你的帮助。
- (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];
}
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];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将 UILabel 添加到您的视图中。
You need to add your UILabel to your view.
您需要调用 :
以便在绘制圆圈之前绘制 uilabel。
You need to call :
in order to draw your uilabel before drawing the circle.