Градиент для бейджей
-(void) drawRoundedRectWithContext:(CGContextRef)context withRect:(CGRect)rect{
CGFloat radius = CGRectGetMaxY(rect)*self.badgeCornerRoundness;
CGFloat puffer = CGRectGetMaxY(rect)*0.10;
CGFloat maxX = CGRectGetMaxX(rect) - puffer;
CGFloat maxY = CGRectGetMaxY(rect) - puffer;
CGFloat minX = CGRectGetMinX(rect) + puffer;
CGFloat minY = CGRectGetMinY(rect) + puffer;
CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
CGFloat locations[3] = { 0.0, 0.5, 1.0 };
CGFloat colors[] =
{
255.0 / 255.0, 200.0 / 255.0, 200.0 / 255.0, 1.00,
230 / 255.0, 0.0 / 255.0, 0.0 / 255.0, 1.00,
190 / 255.0, 0.0 / 255.0, 0.0 / 255.0, 1.00,
};
CGGradientRef gradient = CGGradientCreateWithColorComponents(rgb, colors, locations, 3);
CGColorSpaceRelease(rgb);
CGContextBeginPath(context);
CGContextAddArc(context, maxX-radius, minY+radius, radius, M_PI+(M_PI/2), 0, 0);
CGContextAddArc(context, maxX-radius, maxY-radius, radius, 0, M_PI/2, 0);
CGContextAddArc(context, minX+radius, maxY-radius, radius, M_PI/2, M_PI, 0);
CGContextAddArc(context, minX+radius, minY+radius, radius, M_PI, M_PI+M_PI/2, 0);
// Close the path
CGContextClosePath(context);
CGContextSaveGState(context);
CGContextClip(context);
CGContextDrawLinearGradient(context, gradient, CGPointMake(minX,minY), CGPointMake(minX,maxY), kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
CGContextRestoreGState(context);
}