UISegmetControl
一、UISegmentControl是一个分段控件,父类是UIControl,内涵数个button,并且都有对应下标index;
NSArray *titles = @[@"护卫队",@"三军仪仗队",@"步兵方队",@"炮兵方队"];
UISegmentedControl *SegmentedC = [[UISegmentedControl alloc]initWithItems:titles];
SegmentedC.frame = CGRectMake(20, 40, 335, 40);
SegmentedC.backgroundColor = [UIColor whiteColor];
// 设置文字颜色
SegmentedC.tintColor = [UIColor redColor];
// [SegmentedC setTintColor:[UIColor whiteColor]];
// 默认选中项
SegmentedC.selectedSegmentIndex =0;
// 修改某项的title
[SegmentedC setTitle:@"女兵方阵" forSegmentAtIndex:2];
// 指定某项宽度
[SegmentedC setWidth:100 forSegmentAtIndex:1];
// 设置title 文字大小 颜色
NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:15],NSForegroundColorAttributeName:[UIColor blueColor]};
NSDictionary *dic1 = @{NSFontAttributeName:[UIFont systemFontOfSize:15],NSForegroundColorAttributeName:[UIColor yellowColor]};
[SegmentedC setTitleTextAttributes:dic forState:UIControlStateNormal];
[SegmentedC setTitleTextAttributes:dic1 forState:UIControlStateSelected];
// 添加点击事件
[SegmentedC addTarget:self action:@selector(handleSegmented:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:SegmentedC];
[SegmentedC release];
UISegmetControl的更多相关文章
随机推荐
- Linux系统备份与还原
在使用Ubuntu之前,相信很多人都有过使用Windows系统的经历.如果你备份过Windows系统,那么你一定记忆犹新:首先需要找到一个备份工 具(通常都是私有软件),然后重启电脑进入备份工具提供的 ...
- solr的原子更新/局部更新
solr支持三种类型的原子更新: set - to set a field. add - to add to a multi-valued field. inc - to increment a fi ...
- Qt Add ons Modules(听说QtSystem有接口可以获取 imei号)
http://wiki.qt.io/Qt-Add-ons-Modules 听说QtSystem有接口可以获取 imei号.http://wiki.qt.io/Qt-Add-ons-Modules这儿下 ...
- Android 去除list集合中重复项的几种方法
因为用到list,要去除重复数据,尝试了几种方法.记录于此... 测试数据: List<"}; List<string> li2 = new List<string& ...
- SQL Server中时间段查询和数据类型转换
不知道什么时候对数据独有情种,也许是因为所学专业的缘故,也许是在多年的工作中的亲身经历,无数据,很多事情干不了,数据精度不够,也很多事情干不了,有一次跟一个朋友开玩笑说,如果在写论文的时候,能有一份独 ...
- webstrom使用记录
很不方便的一点: 输入 $("#div p" 之后输入",就会变成$("#div p""" 这样,很不爽.
- CreateObject("Wscript.Shell")用法
WScript.Shell是WshShell对象的ProgID,创建WshShell对象可以运行程序.操作注册表.创建快捷方式.访问系统文件夹.管理环境变量. 该对象有一个run方法. Run 方法创 ...
- [译]GotW #6b Const-Correctness, Part 2
const和mutable对于书写安全代码来说是个很有利的工具,坚持使用它们. Problem Guru Question 在下面代码中,在只要合适的情况下,对const进行增加和删除(包括 ...
- 2、RenderScript的计算(2013.05.07)
一.官方文档翻译: Android Renderscript计算 参考网址: http://blog.csdn.net/fireofstar/article/details/7748143 http: ...
- BZOJ_3207_花神的嘲讽计划1_(Hash+主席树)
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=3207 给出一个长度为\(n\)的串,以及\(m\)个长度为\(k\)的串,求每个长度为\(k\ ...