IOS study every day
The choice of control content scripts is above UISegmentedControl, the general application scenario is basically the function of class UIButton。
(void)viewDidLoad {
[superviewDidLoad];
_se=[[UISegmentedControlalloc]initWithFrame:CGRectMake(0,
60,
self.view.frame.size.width,
40)];
// Add element
[_seinsertSegmentWithTitle:@"1"atIndex:0animated:NO];
[_seinsertSegmentWithTitle:@"2"atIndex:1animated:NO];
// Set default options. Attention must be written in the following elements are added, otherwise no effect.
_se.selectedSegmentIndex=0;
// Method for setting different elements
[
forControlEvents:UIControlEventValueChanged];
[self.view
addSubview:_se];
}
-(void)change{
NSLog(@"%ld",_se.selectedSegmentIndex);
}
– (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}