自定制segmentControl

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_第1张图片

你可能感兴趣的:(自定制segmentControl)