Saturday, July 23, 2011

Create a UISwitch Programmatically


//Add Below code in ViewDidLoad or LoadView


CGRect frame = CGRectMake(0.0, 0.0, 60.0, 26.0);
UISwitch *switchControl = [[UISwitch alloc] initWithFrame:frame];
[switchControl addTarget:self action:@selector(actionSwitch:) forControlEvents:UIControlEventTouchUpInside];

[switchControl setBackgroundColor:[UIColor clearColor]];
[self.view addSubview:switchControl];

No comments:

Post a Comment

Kamleshwar