Bring previously added view to front

 ̄綄美尐妖づ 提交于 2019-12-10 18:34:02

问题


My problem is the following:

I have a view and to that view I add 3 subViews(view1,view2,view3) in that order. The views slightly overlap. I want to bring the first view to the top but I just can't get it to work.

I tried adding the views with insertSubview:atIndex: and giving view1 a larger index and I tried using addSubview: and then bringSubviewToTop but nothing seems to work.

Any ideas?

P.S. I can't add the views in a different order. They have to be added in this order.


回答1:


bringSubviewToFront should work, just make sure you're using it correctly. The usage is.

[parentView bringSubviewToFront:view1];



回答2:


You can try the method bringSubviewToFront:

Moves the specified subview so that it appears on top of its siblings.

- (void)bringSubviewToFront:(UIView *)view

Parameters

  • view: The subview to move to the front.


来源:https://stackoverflow.com/questions/18097952/bring-previously-added-view-to-front

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!