UITableViewCell drawRect画线在iOS7下不显示的问题

在iOS8上运行正常的UITableViewCell在iOS7下画线消失,原因是cell的backgroundColor在iOS7中为白色不透明。解决方法包括设置cell的subviews[0]背景颜色为clearColor,或者确保self.backgroundColor和self.contentView.backgroundColor都为clearColor。
摘要由CSDN通过智能技术生成

- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, kWhite_Color.CGColor);
CGContextFillRect(context, rect);
UIColor *lineColor = HexColor(@"#DBD8D8");
CGFloat lineHeight = LLISIOS8 ? 1/[UIScreen mainScreen].scale : 1;
CGContextSetStrokeColorWithColor(context, lineColor.CGColor);// 线条颜色
CGContextSetLineWidth(context, lineHeight);//线条宽度
CGContextMoveToPoint(context, 0,rect.size.height - lineHeight); //开始画线, x,y 为开始点的坐标
CGContextAddLineToPoint(context, rect.size.width, rect.size.height - lineHeight);//画直线, x,y 为线条结束点的坐标
CGContextStrokePath(context); //开始画线
}

这个是在cell 里面画线的代码,在iOS8上面运行一直没有问题,但同事用他iPhone4s iOS7下测试的时候,cell的线条突然消失了。

Google 了一下,发现cell 在iOS7下 backgroundColor 是白色不透明的,iOS8下 是clea

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值