IOS cotrols隐藏匆匆像机器人 [英] IOS cotrols hide and gone like android
问题描述
我已经使用了故事情节与自动布局我的UI设计。基本上,在机器人有三种不同的属性将在那里例如可见和隐形和走了。
I have used storyboard with autolayout for my UI design. Basically in android there are three different properties will be there like Visible and Invisible and gone.
例如:
1) android:visibility="gone" // used to hide the control and as well as space
(or)
CONTROLNAME.setVisibility(View.GONE);
2) android:visibility="invisible" // used to hide the control but it will take space
(or)
CONTROLNAME.setVisibility(View.INVISIBLE);
在IOS,
1) ?
2) [CONTROLNAME setHidden:TRUE]; // used to hide the control but it will take space
有关充当消失在IOS我已经搜索从谷歌,但我可以没能找到解决方案。
for act as a gone in IOS i have searched from google but i can't able to find the Solution.
推荐答案
要删除一个视图(控制)所占用的空间可以降低尺寸
其框架零或视图层次结构中移除。即通过调用 removeFromSuperview
上的控制。
To remove the space occupied by a view(control) can either reduce the size
of its frame to zero or remove it from the view hierarchy. I.e. by calling removeFromSuperview
on the control.
例如,如果你要删除一个的UITextField
(比如控件名称
),那么你就可以占用的空间无论是使用:
For example if you have to remove the space occupied by a UITextField
(say CONTROLNAME
), then you can either use:
CGRect tempFrame = CONTROLNAME.frame;
CGSize currentSize = tempFrame.size; //for later use
tempFrame.size = CGSizeZero;
CONTROLNAME.frame = tempFrame;
或
CGRect currentFrame = CONTROLNAME.frame; //for later use
[CONTROLNAME removeFromSuperview];
更新:
在第一种情况下,你将不得不存储较早大小带回控制到其初始位置。
In the first case you will have to store the earlier size to bring back the control to its initial position.
CGRect tempFrame = CONTROLNAME.frame;
tempFrame.size = currentSize; //set to initial value
CONTROLNAME.frame = tempFrame;
在第二种情况下,你将不得不存储控制的框架,使其恢复到初始位置的(以及控件本身,如果它是一个局部变量或弱实例变量)的。
In the second case you will have to store the frame of the control to bring it back to its initial position (and also the control itself if it is a local variable or weak instance variable).
CONTROLNAME.frame = currentFrame;
这篇关于IOS cotrols隐藏匆匆像机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!