美文网首页
自定制segmentControl

自定制segmentControl

作者: 飞不飞 | 来源:发表于2017-02-22 15:05 被阅读0次

    NSArray * arraytitle = @[@"快讯",@"推荐",@"早期项目"];

    UISegmentedControl * segmentControl = [[UISegmentedControl alloc]initWithItems:arraytitle];

    segmentControl.frame = CGRectMake(60, 100, 200, 40);

    segmentControl.selectedSegmentIndex = 1;

    segmentControl.tintColor = [UIColor orangeColor];

    设置监听

    // [segmentControl addTarget:@selector(self) action:@selector(change) forControlEvents:UIControlEventValueChanged];

    [self.view addSubview:segmentControl];

    [segmentControl release];

    -(void) change{

    switch (self.segmControl.selectedSegmentIndex) {

    case 0: {

    }

    break;

    case 1: {

    }

    break;

    }

    }

    注意:需将图中改为No才不会崩溃

    相关文章

      网友评论

          本文标题:自定制segmentControl

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