Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 设置UIView部分的alpha_Iphone_Objective C_View - Fatal编程技术网

Iphone 设置UIView部分的alpha

Iphone 设置UIView部分的alpha,iphone,objective-c,view,Iphone,Objective C,View,当用户点击搜索栏时,我需要使视图的矩形部分变黑。我想不出一个办法。我试过CGRectMake,但我如何设置该矩形的alpha???为什么不在某个事件中添加另一个UIView并将其添加到UIView上?为什么不在某个事件中添加另一个UIView并将其添加到UIView上?添加一个黑色背景的UIImageView: UIImageView *myView= [[UIImageView alloc] initWithFrame:CGRectMake(x, y, width, height)];

当用户点击搜索栏时,我需要使视图的矩形部分变黑。我想不出一个办法。我试过CGRectMake,但我如何设置该矩形的alpha???

为什么不在某个事件中添加另一个
UIView
并将其添加到
UIView
上?

为什么不在某个事件中添加另一个
UIView
并将其添加到
UIView
上?

添加一个黑色背景的UIImageView:

    UIImageView *myView= [[UIImageView alloc] initWithFrame:CGRectMake(x, y, width, height)];
    myView.backgroundColor = [UIColor blackColor];
    [self.view addSubview:myView];
    [myView release];

添加黑色背景的UIImageView:

    UIImageView *myView= [[UIImageView alloc] initWithFrame:CGRectMake(x, y, width, height)];
    myView.backgroundColor = [UIColor blackColor];
    [self.view addSubview:myView];
    [myView release];

可以通过以下方式将子图层添加到视图的图层中来完成此操作

UIView*view=[[UIView alloc]initWithFrame:CGRectMake(50.0,0.01000.01000.0)]自动释放]; view.backgroundColor=[UIColor grayColor]; [self.view addSubview:view]

CALayer *layerUP = [CALayer layer];
[layerUP setFrame:CGRectMake(0.0, 0.0, 100.0, 50.0)];
[layerUP setBackgroundColor:[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0].CGColor];
[view.layer addSublayer:layerUP];

CALayer *layerDown = [CALayer layer];
[layerDown setFrame:CGRectMake(0.0, 50.0, 100.0, 50.0)];
[layerDown setBackgroundColor:[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.2].CGColor];
[view.layer addSublayer:layerDown];

可以通过以下方式将子图层添加到视图的图层中来完成此操作

UIView*view=[[UIView alloc]initWithFrame:CGRectMake(50.0,0.01000.01000.0)]自动释放]; view.backgroundColor=[UIColor grayColor]; [self.view addSubview:view]

CALayer *layerUP = [CALayer layer];
[layerUP setFrame:CGRectMake(0.0, 0.0, 100.0, 50.0)];
[layerUP setBackgroundColor:[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0].CGColor];
[view.layer addSublayer:layerUP];

CALayer *layerDown = [CALayer layer];
[layerDown setFrame:CGRectMake(0.0, 50.0, 100.0, 50.0)];
[layerDown setBackgroundColor:[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.2].CGColor];
[view.layer addSublayer:layerDown];

我有一个搜索栏,当用户点击它时,我使用CatTransition向上移动它,并显示cancel按钮。在这之后,我希望搜索栏下方的其余视图呈黑色。有点像twitter应用程序。Discover Tab我有一个搜索栏,当用户点击它时,我使用CatTransition向上移动它,并显示取消按钮。现在,在这之后,我希望搜索栏下方的其余视图为黑色。有点像twitter应用程序。#发现选项卡