我想添加一個UIView到我的UIViewController,但我希望它是透明的,直到我決定在UIView內創建一個Oval。使UIView透明
直到我創建橢圓,我可以將我的視圖的alpha設置爲0,但是當我想添加橢圓時,背景顏色仍然是黑色。
這裏就是它看起來像一堆橢圓
在我的UIView:
- (void)drawRect:(CGRect)rect
{
[self pushContext];
UIBezierPath *oval = [UIBezierPath bezierPathWithOvalInRect:self.bounds];
[[UIColor redColor] setFill];
[oval fill];
self.opaque = NO;
[self setBackgroundColor:[UIColor clearColor]];
[oval addClip];
[self setBackgroundColor:[UIColor clearColor]];
[self popContext];
}
哦有趣的解決方案!非常感謝 – peter1234 2013-03-15 06:15:23