UISegmentControl 、UIStepper
- UISegmentControl
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/max2.@property(nonatomic) double minimumValue; // default 0. must be less than maximumValue3.@property(nonatomic) double maximumValue; // default 100. must be greater than minimumValue4.@property(nonatomic) double stepValue; // default 1. must be greater than 05.
- 简单了解一些属性
时间: 2024-10-13 02:39:08