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;
}
}
网友评论