首页 技术 正文
技术 2022年11月10日
0 收藏 396 点赞 2,974 浏览 1357 个字

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.}

UISegmentControl 、UIStepper

  • 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.

 

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,492
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,495
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,132
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,295