ios分段控制器

2018-11-03  本文已影响0人  elephant0001

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;

    }

}

上一篇 下一篇

猜你喜欢

热点阅读