Translate

> > UISwitch View Example

UISwitch View Example

Posted on Monday, April 4, 2011 | No Comments



Dynamic Switch button Event Making Code


- (void)viewDidLoad {
    [super viewDidLoad];
[switc2 addTarget:self action:@selector(changeSwitch2) forControlEvents:UIControlEventValueChanged];
}

-(void) changeSwitch2 {
if (switc2.on) {
image1.image = [UIImage imageNamed:@"on.png"];
} else {
image1.image = [UIImage imageNamed:@"off.png"];
}

}

For Static Switch button Event Code
create an IBAction in header file

-(IBAction) switchclick:(id)sender {
if (switc.on) {
image1.image = [UIImage imageNamed:@"on.png"];
} else {
image1.image = [UIImage imageNamed:@"off.png"];
}

Leave a Reply

Powered by Blogger.