一、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. codeforces 388B Fox and Minimal path

    这个题目的突破口就是固定最短长度,然后以二进制的形式分层: 最后把需要的曾连起来: #include<cstdio> #include<cstring> #define max ...

  2. jquery ashx

    http://www.cnblogs.com/wzcheng/archive/2010/05/20/1739810.html http://www.cnblogs.com/yyl8781697/arc ...

  3. AHB总线和APB总线

    AHB主要用于高性能模块(如CPU.DMA和DSP等)之间的连接,作为SoC的片上系统总线,它包括以下一些特性:单个时钟边沿操作:非三态的实现方式:支持突发传输:支持分段传输:支持多个主控制器:可配置 ...

  4. Altium Designer学习: 原理图和PCB元件对应查找

    画PCB的时候,需要经常的去查看原理图上对应的元件,元件数目少还好找,数目多了找起来就比较扯淡.还要Altium Designer提供了不错的交叉查找功能. 这里我建议使用两个显示器,一个显示器放原理 ...

  5. 3.5MM/2.5MM耳机插头定义

    自2009年国内手机耳机接口统一以来,现在国内销售耳机基本就3.5MM和2.5MM两种,当然也有很少BT厂家,就是不用这两种,比如使用MiniUSB等接口作为耳机接口.3.5mm耳机插头按照结构划分, ...

  6. Java-Swing嵌入浏览器(二)

    这是qtjambi利用webview来做嵌入式浏览器,下面是我的工程目录. 运行效果如下图: 代码相关: package qtBowers; import com.trolltech.qt.core. ...

  7. Oracle 常用符号CHR

    select  chr(92)||chr(102) from dual; \f select  chr(92)||chr(110) from dual; \n select  chr(92)||chr ...

  8. [NYOJ 43] 24 Point game

    24 Point game 时间限制:3000 ms  |  内存限制:65535 KB 难度:5   描述 There is a game which is called 24 Point game ...

  9. DD_belatedPNG,IE6下PNG透明解决方案

    我们知道IE6是不支持透明的PNG的,这无疑限制了网页设计的发挥空间. 然而整个互联网上解决这个IE6的透明PNG的方案也是多不胜数,从使用IE特有的滤镜或是e­xpression,再到javascr ...

  10. apple mac 下使用机械键盘的办法,键盘映射工具软件,apple mac Mechanical keyboard

    apple mac 下使用机械键盘的办法,键盘映射工具软件,apple mac Mechanical keyboard 想在苹果电脑 mac 系统下使用 机械键盘,大部分机械键盘不是为mac设计的,所 ...