Expandable View in iOS

570 Views Asked by At

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.

1

There are 1 best solutions below

0
On

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.