首页 > 系统 > iOS > 正文

IOS study every day - UISegmentedControl

2019-11-06 07:42:19
字体:
来源:转载
供稿:网友

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.

}

转自:点击打开文章来源链接


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表