Objective--C UISegmentedControl 交通灯
来源:互联网 发布:linux shell exec 编辑:程序博客网 时间:2024/05/29 15:31
只是简单的点击变化背景颜色,主要记录UISegmentedControl的使用
在viewDidLoad方法下
NSArray *segArr = [[NSArrayalloc] initWithObjects:@"red",@"yellow",@"green",nil];
UISegmentedControl *seg = [[UISegmentedControlalloc] initWithItems:segArr];
seg.frame = CGRectMake(100, 100, 200, 50);
seg.backgroundColor = [UIColorcyanColor];
[seg addTarget:selfaction:@selector(click:)forControlEvents:UIControlEventValueChanged];
[self.viewaddSubview:seg];
[seg release];
// 点击事件的实现
- (void)click:(UISegmentedControl *)seg{
NSInteger i = seg.selectedSegmentIndex;
switch (i) {
case 0:
self.view.backgroundColor = [UIColorredColor];
break;
case 1:
self.view.backgroundColor = [UIColoryellowColor];
break;
case 2:
self.view.backgroundColor = [UIColorgreenColor];
break;
default:
break;
}
}
- Objective--C UISegmentedControl 交通灯
- Objective-C-iOS常用小控件(UISegmentedControl)
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- 大数据告诉你:美联储若加息将如何影响A股
- Java学习之final关键词
- Intent详细介绍及使用实例
- url是jsp后跟参数
- oracle 创建表空间,用户并授权
- Objective--C UISegmentedControl 交通灯
- 逆向工程(一):汇编、逆向工程基础篇
- 第9周项目2 - 对称矩阵压缩存储的实现与应用(1).cpp
- leetcode刷题日记——Excel Sheet Column Number
- Struts2获取request的几种方式汇总(list对象获取)
- 查找
- 文章标题
- 第9周项目2 - 对称矩阵压缩存储的实现与应用(2).cpp
- Hadoop安装过程遇到的坑: