Iphone 如何仅在添加子视图之前在旧视图中设置Alpha或不透明度

Iphone 如何仅在添加子视图之前在旧视图中设置Alpha或不透明度,iphone,opacity,alpha,Iphone,Opacity,Alpha,我不知道,如何在界面中设置旧视图以仅在旧视图中减少alpha 不减少新视图 我有这个功能 -(IBAction)save:(id)sender { testView * subTestview = [[testView alloc]initWithNibName:@"TestView" bundle:nil]; subTestview.view.frame = CGRectMake(0, 0, subTestview.view.frame.size.width,

我不知道,如何在界面中设置旧视图以仅在旧视图中减少alpha

不减少新视图

我有这个功能

-(IBAction)save:(id)sender
{
    testView * subTestview = [[testView alloc]initWithNibName:@"TestView" bundle:nil];
    subTestview.view.frame = CGRectMake(0, 0, subTestview.view.frame.size.width,
                                        subTestview.view.frame.size.height);
    subTestview.view.center = CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2);
    self.view.alpha = 0.3f;
    [self.view addSubview:subTestview.view];
}
当我使用“self.view.alpha=0.3f”时,它会降低所有视图的alpha

请帮帮我

多谢各位


我认为,你应该提出另一种家长观点。把你的testView放在上面。将您的子测试视图也独立地放在上面(不是作为testView的子视图,而是作为父视图的子视图)。然后尝试设置testView的alpha

我认为,你应该提出另一种家长观点。把你的testView放在上面。将您的子测试视图也独立地放在上面(不是作为testView的子视图,而是作为父视图的子视图)。然后尝试设置testView的alpha

尝试以下代码以将视图控制器添加为当前视图中的子视图

CurrentViewController.m

PopUpViewController *popUpViewController = [[PopUpViewController alloc] initWithNibName:@"PopUpViewController" bundle:nil];
popUpViewController.view.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.9f];
popUpViewController.view.frame = self.view.frame;
[self.view addSubview: popUpViewController.view];
[self addChildViewController: popUpViewController];

尝试以下代码将视图控制器添加为当前视图中的子视图

CurrentViewController.m

PopUpViewController *popUpViewController = [[PopUpViewController alloc] initWithNibName:@"PopUpViewController" bundle:nil];
popUpViewController.view.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.9f];
popUpViewController.view.frame = self.view.frame;
[self.view addSubview: popUpViewController.view];
[self addChildViewController: popUpViewController];