一、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的更多相关文章

随机推荐

  1. ping(1)

    /* ping program for learning IP protocol author: jeff date: 2014/10/25 */ #include <stdio.h> # ...

  2. android对大图片的缓存处理

    废话不多说,直接上代码 package com.huge.emj.common.util; import java.io.File; import java.io.FileInputStream; i ...

  3. linux下查看机器的硬件信息:

    查看CPU信息(型号) # cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c       8  Intel(R) Xeon(R) CPU    ...

  4. asp.net DropDownList无刷新ajax二级联动实现详细过程

    只适合新手制作DropDownList无刷新ajax二级联动效果: 数据库实现,添加两表如图:表1,pingpai,表2,type,具体数据库实现看自己的理解: //页面主要代码: <asp:S ...

  5. 使用Timer执行定时任务

    一.Timer概述 在Java开发中,会碰到一些需要定时或者延时执行某些任务的需求,这时,我们可以使用Java中的Timer类实现. 二.Timer介绍 Timer是一个定时器类,通过该类可以为指定的 ...

  6. RPGJS 进阶分析之 如何使用RMXP导出的数据

    首先启动RMXP 在主脚本编辑区粘贴官方提供的导出数据脚本. 之后启动并进入游戏之后按F8键就可以调出导出Map和Animation的菜单 导出后的数据保存在工程目录下的RpgJs目录下. Datab ...

  7. Linq中的常用方法

    System.Linq System.Linq.Enumerable  类 Range Repeat Reverse Select Where Sum Zip Aggregate Count Firs ...

  8. How to: Define a Windows Communication Foundation Service Contract

    This is the first of six tasks required to create a basic Windows Communication Foundation (WCF) app ...

  9. 免安装oracle驱动访问数据库

    try { string connStr = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.110.110)( ...

  10. 【转】国内用户如何加快App Store的访问速度

    原文网址:http://www.app111.com/doc/100024206_1.html 作为国内互联网用户是比较可怜的,除了国外四大顶尖互联网服务不能访问外,就是App Store用得也比较痛 ...