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
[_seaddTarget:selfaction:@selector(change)forControlEvents:UIControlEventValueChanged];
[self.viewaddSubview:_se];
}
-(void)change{
NSLog(@"%ld",_se.selectedSegmentIndex);
}
– (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
转自:点击打开文章来源链接
新闻热点
疑难解答