我想在我的UIViewController中添加一个UIView,但我希望它是透明的,直到我决定在UIView中创建一个Oval.
在我创建椭圆之前,我可以将视图的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];
}
Run Code Online (Sandbox Code Playgroud) 我几天前开始学习Python,并在编写代码时遇到了一个程序.
这是我想用C++代码做的事情
number = SOME_NUMBER;
while(1) {
for(int i=number; i<sizeOfArray; i++) {
// do something
}
number = 0;
}
Run Code Online (Sandbox Code Playgroud)
基本上,对于我的for循环的第一次迭代,我想从数字开始.然后每隔一段时间我都会通过for循环,我想在0开始.
我现在能想到的那种愚蠢的想法是做一些像:
number = SOME_NUMBER
for i in range(0, len(array)):
if i != number:
continue
// do something
while True:
for i in range(0, len(array)):
// do something
Run Code Online (Sandbox Code Playgroud)
这是最好的方式还是有更好的方法?