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的更多相关文章
随机推荐
- 背投广告js
js: $('#appwrap').append('<a href="http://web.2144.cn/gateway/reg?pos=8966" id="ad ...
- Spring中的一个错误:使用Resources时报错(The annotation @Resources is disallowed for this location)
在学习Spring的过程中遇到一个错误:在使用注解@resources的时候提示:The annotation @Resources is disallowed for this location 后 ...
- responsive web design
http://d.alistapart.com/responsive-web-design/ex/ex-site-flexible.html http://alistapart.com/article ...
- Linux内核spin_lock与spin_lock_irq分析
http://blog.csdn.net/zhanglei4214/article/details/6837697
- ANDROID_MARS学习笔记_S01原始版_006_ListView
一.代码1.xml(1)main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayo ...
- 【HDOJ】3016 Man Down
线段树+spfa求最长路.逆向思维,从最底下一块板子建图.需要注意的是任何一个板子掉落下面再无板子,此时都可以看做一个终结状态. /* 3016 */ #include <iostream> ...
- Item Import: What Does "Sync" Items Do? (Doc ID 417887.1)
In this Document Goal Solution APPLIES TO: Oracle Item Master - Version 11.5.10.0 to 11.5.10.0 [Rele ...
- EasyUI中datagrid的行编辑模式中,找到特定的Editor,并为其添加事件
有时候在行编辑的时候,一个编辑框的值要根据其它编辑框的值进行变化,那么可以通过在开启编辑时,找到特定的Editor,为其添加事件 // 绑定事件, index为当前编辑行 var editors = ...
- Apache搭建多个站点
如何用Apache搭建的网站系统上运行多个站点呢?最平常的大概有3种方法. 第一种:单IP不同端口 第二种:多IP同端口(独立IP的虚拟空间) 第三种:域名绑定根目录的方式(共享IP的虚拟空间) 下面 ...
- 多组 RadioButtonList 获取值
<div class="row"> <table> <thead><tr><th>操作</th ...