UISegmentedControl简单使用

NSArray * segMArr = [NSArray arrayWithObjects:@”0,@”1, nil];

UISegmentedControl * segmentC = [[UISegmentedControl alloc]initWithItems:segMArr];

    segmentC.frame = CGRectMake(0, 178, 320, 30);

    segmentC.segmentedControlStyle = UISegmentedControlStylePlain;

    segmentC.tintColor = [UIColor BlueColor];

    segmentC.selectedSegmentIndex = 0;

    [segmentC addTarget:self action:@selector(segmentedControlSelected:) forControlEvents:UIControlEventValueChanged];

    [bgView addSubview:segmentC];

– (void)segmentedControlSelected:(UISegmentedControl*)seg{

    if (seg.selectedSegmentIndex == 0) {

        

    }else if (seg.selectedSegmentIndex == 1){

    

    }

}

Posted in iOS

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据