UISegmentControl 、UIStepper
2016-02-22 20:44
417 查看
UISegmentControl 、UIStepper
UISegmentControl1. 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.
相关文章推荐
- Android Build (1) -- Source Code Build Steps
- 一个关于 UIPickerView 的 bug
- 1099. Build A Binary Search Tree (30)
- 被玩坏的innerHTML、innerText、textContent和value属性
- HDU1711-Number Sequence-KMP
- 1.UILabel
- iOS蓝牙开发(四):BabyBluetooth蓝牙库介绍
- ZOJ 3210 A Stack or A Queue?(暴力)
- StringBuilder StringBuffer区别
- CCSprite精灵类创建、坐标系OpenGL、坐标系UIKit坐标系(屏幕坐标系)-----
- LeetCode-Range Sum Query - Immutable
- 选中输入框上弹视图
- 基于UIKit下的UIView动画
- String、StringBuilder、StringBuffer
- UIVisualEffectView(自定义模糊视图)
- SSH+Easyui之combotree ,TreeGrid 树形展现数据
- SourceTree——MAC OSX下的Git GUI客户端
- UINavigationController + UIScrollView组合,视图尺寸的设置探秘(三)
- UINavigationController + UIScrollView组合,视图尺寸的设置探秘(二)
- UINavigationController + UIScrollView组合,视图尺寸的设置探秘(一)