Att Ios Ui Switches
## Using iOS Switches
Switches are used to toggle between on and off states.
Important Properties
* onImage
* offImage
* on
### Important Method
- (void)setOn:(BOOL)on animated:(BOOL)animated
### Add Custom Method addSwitch and the Switch
-(IBAction)switched:(id)sender{ NSLog(@"Switch current state %@", mySwitch.on ? @"On" : @"Off");}-(void)addSwitch{ mySwitch = [ init]; [self.view addSubview:mySwitch]; mySwitch.center = CGPointMake(150, 200); [mySwitch addTarget:self action:@selector(switched:) forControlEvents:UIControlEventValueChanged]; }
### Modify viewDidLoad in ViewController.m as shown below
(void)viewDidLoad { ; ;}
### Output
Now when we run the application, we will see the following output:

Sliding the switch to the right produces the following output:

YouTip