- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);
CGContextFillRect(context, rect);
if ( self.tag == 0) {
//上分割线,
CGContextSetStrokeColorWithColor(context, [ UIColor colorWithRed:196.0f/255.0f green:196.0f/255.0f blue:196.0f/255.0f alpha:1.0f ].CGColor);
CGContextStrokeRect(context, CGRectMake(0, -0.5f, rect.size.width, 0.5f));
}
//下分割线
CGContextSetStrokeColorWithColor(context, [ UIColor colorWithRed:196.0f/255.0f green:196.0f/255.0f blue:196.0f/255.0f alpha:1.0f ].CGColor);
CGContextStrokeRect(context, CGRectMake(0, rect.size.height, rect.size.width , 0.5f));
}
或
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
CGContextFillRect(context, rect);
CGContextSetStrokeColorWithColor(context, ColorSystemDefultDividerLine.CGColor);
CGContextStrokeRect(context, CGRectMake(Spacing, rect.size.height - 0.25, rect.size.width, 0.25));
}