IOS cotrols隐藏起来就像android一样

Pra*_*h S 12 android objective-c ios autolayout swift

我在自己的UI设计中使用了自动布局的故事板.在android中基本上有三种不同的属性,如Visible,Invisible不见了.

例如:

   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);
Run Code Online (Sandbox Code Playgroud)

在IOS,

Objective-C的

  1) ?
  2) [CONTROLNAME setHidden:TRUE]; // used to hide the control but it will take space
Run Code Online (Sandbox Code Playgroud)

迅速

  1) ?
  2) CONTROLNAME.isHidden = true  // used to hide the control but it will take space
Run Code Online (Sandbox Code Playgroud)

作为IOS 消失的行为我从谷歌搜索但我无法找到解决方案.

Rak*_*esh 5

要删除视图(控件)所占用的空间,可以将size其框架的减小为零,也可以将其从视图层次结构中删除。即通过调用removeFromSuperview控件。

例如,如果必须删除UITextField(say CONTROLNAME)占用的空间,则可以使用:

CGRect tempFrame = CONTROLNAME.frame;
CGSize currentSize = tempFrame.size; //for later use
tempFrame.size = CGSizeZero;
CONTROLNAME.frame = tempFrame;
Run Code Online (Sandbox Code Playgroud)

要么

CGRect currentFrame = CONTROLNAME.frame; //for later use
[CONTROLNAME removeFromSuperview];
Run Code Online (Sandbox Code Playgroud)

更新:

在第一种情况下,您将必须存储较早的大小以使控件返回到其初始位置。

CGRect tempFrame = CONTROLNAME.frame;
tempFrame.size = currentSize; //set to initial value
CONTROLNAME.frame = tempFrame;
Run Code Online (Sandbox Code Playgroud)

在第二种情况下,您将必须存储控件的框架以将其恢复到初始位置(如果控件是局部变量或弱实例变量,则还必须保存控件本身)

CONTROLNAME.frame = currentFrame;
Run Code Online (Sandbox Code Playgroud)