我有一个默认情况下应该被 imageView 隐藏的 containerView,在启动时图像应该覆盖容器。然而,即使 IB 中的分层是正确的,并且在容器之后更新了 imageView,容器仍然显示在图像前面。有没有办法阻止这种情况发生?
这是IB的大纲:
当我第一次发布这个时,我有图像视图,以及主视图中视图上的三个按钮。但从那以后,我将其更改为显示方式。
鉴于我对每个子视图都有如下出口:Container View-Container、Image View-backgroundImage、Buttons-item1、item2、item3。
这是我尝试过的事情的清单:
[self.view sendSubviewToBack: _Container];
[self.view bringSubviewToFront: _item1];
[self.view bringSubviewToFront: _item2];
[self.view bringSubviewToFront: _item3];
[self.view bringSubviewToFront: _backgroundImage];
我还尝试将容器视图从视图控制器的可见坐标中移出,但这也不起作用。
这也是我的视图控制器的 viewDidAppear 方法:
首先,我设置容器视图,然后对按钮和图像视图进行一些初始设置。在这个方法的底部是我放置子视图命令的地方。希望这会有所帮助。
-(void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self.containerViewController performSegueWithIdentifier:@"embedConverter" sender:nil];
_item1.center = self.view.center;
_item2.center = self.view.center;
_item3.center = self.view.center;
_item1.layer.anchorPoint = CGPointMake(.5,1.5);
_item3.layer.anchorPoint = CGPointMake(.5,-.5);
CGAffineTransform move1 = CGAffineTransformMakeTranslation(0, -15);
CGAffineTransform move3 = CGAffineTransformMakeTranslation(0, 15);
_item1.transform = move1;
_item3.transform = move3;
[_item1 setTranslatesAutoresizingMaskIntoConstraints:YES];
[_item2 setTranslatesAutoresizingMaskIntoConstraints:YES];
[_item3 setTranslatesAutoresizingMaskIntoConstraints:YES];
CGAffineTransform scale = CGAffineTransformMakeScale(1.25, 1.25);
_item1.transform = scale;
_item2.transform = scale;
_item3.transform = scale;
_item1.alpha = menuAlpha;
_item2.alpha = menuAlpha;
_item3.alpha = menuAlpha;
_menuBackground.image = [self applyBlurWithRadius:10
tintColor:[UIColor colorWithWhite:.3 alpha:.7]
saturationDeltaFactor:1
maskImage:nil];
}