iPhone - how may I hide a view and let it's space be used by other view (like android visibility = GONE)

牧云@^-^@ 提交于 2019-12-23 15:14:16

问题


Do you know a simple (or not simple) way to hide a view (or anything like a view) and let the other views of the screen use the place left blank ? And make the opposite when showing back that view. Something like Android Visibility = GONE for layers.

As far as I know, using setHidden=YES only hide the view from the screen but does not rearrange anything around it.

On Android, there are 2 hidding method. One like visibility = HIDE, and the other : visibility = GONE.

Let's say we have 3 views each with an height of 100px. On Android : If you set view2 visibility = HIDE, it just hides, and nothing else happens. If you set view2 visibilty = GONE, the view2 hides from the screen and the view3 automaticaly takes the place freed by view2.

That's what I'm looking to on the iPhone. I imagine there no auto way to do this but do you know any snippet or code making this possible ?

Thank you


回答1:


There's no auto-tiling in iOS, so the only way to do this is to resize each of the views to how you want them to be yourself, perhaps by implementing layoutSubviews on their superview.



来源:https://stackoverflow.com/questions/4741985/iphone-how-may-i-hide-a-view-and-let-its-space-be-used-by-other-view-like-an

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