打开sketch的iOS原件库。发现cell分割线的css是这样的:
box-shadow: inset 0 0 0 0 #C8C7CC;
为了简单,可以设置uiview高度为0.5像素,颜色为#C8C7CC
。
也可以在drawRect里绘制:
- (void)drawRect:(CGRect)rect{
[super drawRect:rect];
[self drawLineX:0 rect:rect color:[UIColor sg_colorWithHex:0xC8C7CC]];
}
- (void)drawLineX:(CGFloat)x rect:(CGRect)rect color:(UIColor *)color{
[self drawLineX:x length:rect.size.width-x*2 rect:rect color:color];
}
- (void)drawLineX:(CGFloat)x length:(CGFloat)w rect:(CGRect)rect color:(UIColor *)color{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);
CGContextFillRect(context, rect);
CGContextSetStrokeColorWithColor(context,color.CGColor);
CGContextStrokeRect(context, CGRectMake(x, rect.size.height, w, 1));
[self.subviews[0] setBackgroundColor:[UIColor clearColor]];
}