标签:
1. UISegmentedControl *segmentControl = [[UISegmentedControl alloc] initWithItems:@[@"1",@"2",@"3",@"4"]];
2.segmentControl.frame = (CGRect){50,100,100,50};
等同于
1. UISegmentedControl *segmentControl = [[UISegmentedControl alloc]
2. initWithFrame:CGRectMake(50, 100, 100, 50)];
3.
4. [segmentControl insertSegmentWithTitle:@"1" atIndex:0 animated:YES];
5. [segmentControl insertSegmentWithTitle:@"2" atIndex:1 animated:YES];
6. [segmentControl insertSegmentWithTitle:@"3" atIndex:2 animated:YES];
7. [segmentControl insertSegmentWithTitle:@"4" atIndex:3 animated:YES];
其监听事件是值改变事件
1. [segmentControl addTarget:self action:@selector(valueChange:)
2. forControlEvents:UIControlEventValueChanged];
1.-(void)valueChange:(UISegmentedControl *)sender{
2.
3. UIColor *red = [UIColor redColor];
4. UIColor *green = [UIColor purpleColor];
5. UIColor *purple = [UIColor greenColor];
6. UIColor *gray = [UIColor grayColor];
7.
8. NSArray *array = @[red,green,purple,gray];
9.
10. NSInteger index = sender.selectedSegmentIndex;
11. self.view.backgroundColor = array[index];
12.}
UIStepper
1.@property(nonatomic) double value; // default is 0. sends UIControlEventValueChanged. clamped to min/max
2.@property(nonatomic) double minimumValue; // default 0. must be less than maximumValue
3.@property(nonatomic) double maximumValue; // default 100. must be greater than minimumValue
4.@property(nonatomic) double stepValue; // default 1. must be greater than 0
5.
标签:
原文地址:http://www.cnblogs.com/buakaw/p/5208107.html