美文网首页
ios分段控制器

ios分段控制器

作者: elephant0001 | 来源:发表于2018-11-03 15:19 被阅读0次

UISegmentedControl *segment = [[UISegmentedControl alloc]initWithItems:@[@"关注",@"足球",@"篮球"]];

    segment.frame=CGRectMake(0,0,240,40) ;

    segment.tintColor= [UIColorredColor];

    segment.selectedSegmentIndex = 0;

    [segmentaddTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];

    self.navigationItem.titleView = segment;

    FootView = [[FootViewController alloc]init];

    BasketView = [[BasketViewController alloc]init];

- (void)segmentAction:(UISegmentedControl*)segmt {

    intindex = (int)segmt.selectedSegmentIndex;

    switch(index) {

        case0:

            [FootView.view removeFromSuperview];

            [BasketView.view removeFromSuperview];

            break;

        case1:

            [self.viewaddSubview:FootView.view];

            [BasketView.view removeFromSuperview];

            break;

        case2:

            [self.viewaddSubview:BasketView.view];

            [FootView.view removeFromSuperview];

            break;

        default:

            break;

    }

}

相关文章

网友评论

      本文标题:ios分段控制器

      本文链接:https://www.haomeiwen.com/subject/ugvkxqtx.html