- (void)drawRect:(CGRect)rect
{
if ([self.state isEqualToString:@"1"]) {//上圓角
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerTopLeft cornerRadii:CGSizeMake(10, 10)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.bounds;
maskLayer.path = maskPath.CGPath;
self.layer.mask = maskLayer;
} else if([self.state isEqualToString:@"2"]) {//下圓角
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerBottomRight | UIRectCornerBottomLeft cornerRadii:CGSizeMake(10, 10)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.bounds;
maskLayer.path = maskPath.CGPath;
self.layer.mask = maskLayer;
}
//儲存格分割線
CALayer *bottomBorder = [CALayer layer];
bottomBorder.frame = CGRectMake(0,self.frame.size.height-1,self.frame.size.width, 1);
bottomBorder.backgroundColor = COLOR_SEP.CGColor;
[self.layer addSublayer:bottomBorder];
}