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的更多相关文章
随机推荐
- Weex详解:灵活的移动端高性能动态化方案
原文地址:http://www.infoq.com/cn/articles/introducing-weex 在2016年4月份的QCon上,阿里巴巴资深总监,淘宝移动平台及新业务事业部.阿里百川负责 ...
- EasyUI 关于IE使用window组件上传文件
有时候IE会对使用window组件上传文件(第二次)不生效,解决方案是: 将该window每次打开的时候,使用: $('#adUploadWindow').window('refresh', 'pan ...
- 164. Maximum Gap
题目: Given an unsorted array, find the maximum difference between the successive elements in its sort ...
- HDU 2493 Timer 数学(二分+积分)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2493 题意:给你一个圆锥,水平放置,圆锥中心轴与地面平行,将圆锥装满水,在圆锥某一表面开一个小洞,流出来 ...
- 【HDOJ】1076 An Easy Task
水题,如题. #include <stdio.h> #define chk(Y) (Y%4==0 && Y%100!=0) || Y%400==0 int main() { ...
- Android开发UI之Fragment-Tabbed Activity的使用
使用ADT新建的时候,可以选择Tabbed Activity,选择新建一个工程. 新建的工程中,选择不同的Tab页显示不同的内容,主要是通过SectionsPagerAdapter类中的Fragmen ...
- java集合类——Stack类
查看java的API文档,Stack继承Vector类. 栈的特点是后进先出. API中Stack自身的方法不多,基本跟栈的特点有关. import java.util.Stack; public c ...
- 《C#并行编程高级教程》第7章 VS2010任务调试 笔记
没有什么好说的,主要是将调试模式下的Parallel Tasks窗体和Parallel Stacks窗体.折腾一下应该比看书效果好.(表示自己没有折腾过) 另外值得注意的是,主线程不是一个任务.所以主 ...
- PowerDesigner一些小技巧
1.安装PD v12.0版 2.由pdm生成建表脚本时,字段超过15字符就发生错误(oracle) 原因未知,解决办法是打开PDM后,会出现Database的菜单栏,进入Database - Edit ...
- OpenLayers 项目完整分析——(二)源代码总体结构分析
转自:http://www.cnblogs.com/lzlynn/archive/2008/07/29/1255848.html 二)源代码总体结构分析 通过前面的项目介绍,我们大概已经知道Openl ...