Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想放置在按钮单击时显示的 UIImageView。如果我把它放在 Storyboard 的最后一个地方,那效果很好。当我以编程方式执行一些动画时会出现问题,然后我单击按钮以显示 UIImageView 并且它不在屏幕的前面位置。
你可以使用bringSubviewToFront:方法。像这样的东西:
bringSubviewToFront:
[self.view bringSubviewToFront:imageView];
如果您要添加和删除子视图,则视图的顺序可能会发生变化。
一种解决方案是将视图保留在原处,仅修改hidden属性或alpha.
hidden
alpha
另一种解决方案是使用insertSubviewAtIndex:而不是addSubview:.
insertSubviewAtIndex:
addSubview:
此外,您还可以使用bringSubviewToFront:只是为了确保。