0

我在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);

但是,由于我使用 0.4 alpha 作为内部颜色,内部颜色变为棕色。

我怎么能有这样的东西,如下所示?

在此处输入图像描述

4

1 回答 1

1

我只会制作一个矩形,用青色填充它,然后用红色描边。确保将笔划宽度设置为所需的大小。

于 2014-02-06T03:44:04.123 回答