有没有办法可以在 iOS 中实现这一点。
例如,当用户打开开关时,视图将自动取消隐藏,反之亦然。
*(UITextField) (Switch)
-(UITextField) //this is the view that will be hidden/unhidden
-(UITextField) //this is the view that will be hidden/unhidden
我希望有一个人可以帮助我。
有没有办法可以在 iOS 中实现这一点。
例如,当用户打开开关时,视图将自动取消隐藏,反之亦然。
*(UITextField) (Switch)
-(UITextField) //this is the view that will be hidden/unhidden
-(UITextField) //this is the view that will be hidden/unhidden
我希望有一个人可以帮助我。
是的,您可以通过点击开关来隐藏/取消隐藏视图。例如,您可以UIButton
在操作方法的实现中用作开关并隐藏您的视图。
- (IBAction)handleButtonClick:(id)sender {
self.subview1.hidden = YES;
self.subview2.hidden - NO;
}
这是一个很好的教程,可以帮助您开始使用UIButton
和处理操作。
或者,您可以改为使用UISwitch
来实现相同的效果。您可能会发现本教程很有用。
更新:如果您想“扩展”您的子视图,只需相应地更新frame
该特定子视图的属性。