I want to create a custom cell like one in the Mint app which does pretty much the same thing. How do I go about drawing the two bars using the earned and spent data?
Thanks,
I got this far:
-(void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
UIColor * earningStartColor = [UIColor colorWithRed:15/255.0f green:227/255.0f blue:0/255.0f alpha:1.0f];
UIColor * earningEndColor = [UIColor colorWithRed:15/255.0f green:188/255.0f blue:0/255.0f alpha:1.0f];
CGRect earningRect = CGRectMake(5, 32, 60, 13);
UIBezierPath *pathE = [UIBezierPath bezierPathWithRoundedRect:earningRect
cornerRadius:3.0];
[pathE addClip];
drawGlossAndGradient(context, earningRect, earningStartColor.CGColor, earningEndColor.CGColor);
UIColor * spentStartColor = [UIColor colorWithRed:255/255.0f green:88/255.0f blue:67/255.0f alpha:1.0f];
UIColor * spentEndColor = [UIColor colorWithRed:255/255.0f green:52/255.0f blue:49/255.0f alpha:1.0f];
CGRect spentRect = CGRectMake(5, 52, 25, 13);
UIBezierPath *pathS = [UIBezierPath bezierPathWithRoundedRect:spentRect
cornerRadius:5.0];
[pathS addClip];
drawGlossAndGradient(context, spentRect, spentStartColor.CGColor, spentEndColor.CGColor);
}
However, after addClip the drawing stops so only one bar is displayed. If i wrapped addClip around CGContextSaveGState & CGContextRestoreGState, only the second bar corners are rounded.
I also tried subclass a view and draw on the view then add as a subview to my tableviewcell and use cornerRadius, but the drawing is actually lying behind the view, so it appears as the rounded view (with its background) with the rectangle bar behind. I thought this should be easier than it is.