LPPloveROU 2013-04-25 03:36 采纳率: 50%
浏览 2803

在UITableViewcell中划线

drawRect代码如下:

-(void)drawRect:(CGRect)rect
{
    [super drawRect:rect];
    CGContextRef cxt = UIGraphicsGetCurrentContext();
    CGContextSetLineWidth(cxt, 2.0);
    CGContextSetStrokeColorWithColor(cxt, [UIColor redColor].CGColor);
    CGContextMoveToPoint(cxt, 250.0 , 0.0);
    CGContextAddLineToPoint(cxt, 250.0, 50.0);
   CGContextStrokePath(cxt);
}

会画出红色的线。但是一设置cell的背景线就会消失。设置背景的代码:

UIView *view = [[UIView alloc] initWithFrame:cell.frame];
        view.backgroundColor = [UIColor grayColor];
    cell.backgroundView = view;

怎么回事?为什么背景会隐藏起来红线呢?谢谢您的解答。

  • 写回答

1条回答 默认 最新

  • 睡觉不盖被 2015-08-25 08:33
    关注

    我觉得是 backgroundView 的大小 正好 覆盖了 你划的线 看代码 你的线 应该是在边界的位置吧

    评论

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退