我正在尝试在具有黑色边框的UIView中绘制一个透明矩形。
然而,我的代码创建了一个完全黑色的矩形。以下是我目前的代码:
- (void)drawRect:(CGRect)rect
{
// Drawing code
CGRect rectangle = CGRectMake(0, 100, 320, 100);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 0.5);
CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 0.5);
CGContextFillRect(context, rectangle);
}
CGContextFillRect
更改为CGContextStrokeRect
。 - Eric Qian