ios – 无法在UITableViewCell的drawRect中绘制

ios – 无法在UITableViewCell的drawRect中绘制,第1张

概述我在使用自定义UITableViewCell的drawRect方法时遇到了麻烦.这是我正在使用的代码 - (void)drawRect:(CGRect)rect{ CGContextRef ctx = UIGraphicsGetCurrentContext(); CGPoint origin = _faceView.frame.origin; CGFloat wi 我在使用自定义UItableVIEwCell的drawRect方法时遇到了麻烦.这是我正在使用的代码
- (voID)drawRect:(CGRect)rect{    CGContextRef ctx  = UIGraphicsGetCurrentContext();    CGPoint origin    = _faceVIEw.frame.origin;    CGfloat wIDth     = _faceVIEw.frame.size.wIDth;    CGfloat height    = _faceVIEw.frame.size.height;    CGfloat border    = 2.0f;    CGPoint startPt   = CGPointMake(origin.x + wIDth/2,self.frame.size.height);    CGContextBeginPath(ctx);    CGContextMovetoPoint(ctx,startPt.x,startPt.y);    CGPoint basePt    = CGPointMake(startPt.x,origin.y - height - border);    CGContextAddlinetoPoint(ctx,basePt.x,basePt.y);    CGRect circleRect = CGRectMake(origin.x - border,origin.y - border,wIDth + 2 * border,height + 2 * border);    CGContextAddEllipseInRect(ctx,circleRect);    UIcolor *color = [UIcolor redcolor];    CGContextSetFillcolorWithcolor(ctx,color.CGcolor);    CGContextSetstrokecolorWithcolor(ctx,color.CGcolor);    CGContextSetlinewidth(ctx,1.0f);    CGContextDrawPath(ctx,kCGPathFillstroke);}

我已经调试过以确保所有数值都有意义,看起来它们确实存在.无法真正找出屏幕上没有任何内容的原因.

值得一提的是,这也是一个在笔尖中定义的单元格.我正在使用iOS 7 sdk构建.

有任何想法吗?

tahnks

解决方法 你可能不应该在UItableVIEwCell自己的drawRect中这样做.而是创建一个自定义UIVIEw并将其添加为子视图.

另见this answer.

总结

以上是内存溢出为你收集整理的ios – 无法在UITableViewCell的drawRect中绘制全部内容,希望文章能够帮你解决ios – 无法在UITableViewCell的drawRect中绘制所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1098520.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存