Iphone 设置UIView部分的alpha
当用户点击搜索栏时,我需要使视图的矩形部分变黑。我想不出一个办法。我试过CGRectMake,但我如何设置该矩形的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)];
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应用程序。#发现选项卡