【发布时间】:2010-01-24 01:38:55
【问题描述】:
我仍在努力用 CGContext 画一条线。我实际上已经去画线了,但现在我需要 Rect 的背景是透明的,这样现有的背景才能显示出来。这是我的测试代码:
(void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);
CGContextSetAlpha(context,0.0);
CGContextFillRect(context, rect);
CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);
CGContextSetLineWidth(context, 5.0);
CGContextMoveToPoint(context, 100.0,0.0);
CGContextAddLineToPoint(context,100.0, 100.0);
CGContextStrokePath(context);
}
有什么想法吗?
【问题讨论】:
标签: iphone graphics background transparent cgcontext