UISwitch is one of the best framework of UIKit. To create it programmatically, code:
UISwitch *mySwitch = [[UISwitch alloc] initWithFrame:CGRectMake(50, 100, 0, 0)];
Above range allocates an UISwitch and models its shape. UISwitch has resolved measurements (about 95 px extensive, 27px high), so you have to set the harmonizes for top-left part. Size and size are ignored, you can not create swap lesser or larger by modifying the shape.
To add it to your perspective you should use this code:
[self.view addSubview:mySwitch];
Be standard swap is set to Off. You are able to modify it’s condition programmaticaly using setOn method:
[mySwitch setOn:YES animated:YES];
To swap it rear again to Off use:
[mySwitch setOn:NO animated:YES];
In both above situations UISwitch changes it condition...