Question

I am using the below code in drawRect

CGContextSaveGState(context);

CGMutablePathRef outerPath=[self createPath:rect];

CGMutablePathRef innnerPath=[self createPath:UIEdgeInsetsInsetRect(rect, UIEdgeInsetsMake(10.0, 10.0, 10.0, 10.0)];

CGPathCloseSubpath(outerPath);

CGContextAddPath(context, outerPath);
    CGContextSetFillColorWithColor(context, [UIColor colorWithRed:249.0/255.0 green:38.0/255.0 blue:1.0/255.0 alpha:1.0].CGColor);

CGContextEOFillPath(context);
CGContextDrawPath(context, kCGPathFill);

CGContextAddPath(context, innnerPath);
CGContextSetFillColorWithColor(context, [UIColor colorWithRed:50.0/255.0 green:213.0/255.0 blue:1.0 alpha:0.4].CGColor);
CGContextDrawPath(context, kCGPathFill);

CGContextRestoreGState(context);

But, since I am using 0.4 alpha for the inner colour , the inner colour becomes brown.

How can I have something like this as show in below?

enter image description here

Was it helpful?

Solution

I would just make a single rectangle, fill it with a cyan color, and stroke it with a red color. Make sure you set the stroke width to the size you need.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top