0

Is there a way that I can achieve this in iOS.

for example when a user switch on a switch the view will automatically unhide itself or vice versa.

  *(UITextField)    (Switch)

           -(UITextField) //this is the view that will be hidden/unhidden

           -(UITextField) //this is the view that will be hidden/unhidden

I hope someone can help me.

RonPelayo
  • 376
  • 5
  • 22

1 Answers1

1

Yes, you can hide / unhide views on tap on a switch. For example, you can use UIButton as a switch and hide your views in the implementation of an action method.

- (IBAction)handleButtonClick:(id)sender {
     self.subview1.hidden = YES;
     self.subview2.hidden - NO;
}

Here's a good tutorial which would help you to get started with UIButton and handling actions.

Alternatively, you can achieve the same using UISwitch instead. You may find this tutorial useful.

Update: If you want to "expand" your subview, just update accordingly frame property of that particular subview.

Rinat Khanov
  • 1,566
  • 10
  • 32