一、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. js为链接绑定点击事件并且附带return false;来阻止跳转

    <!DOCTYPE HTML> <html> <head> <meta charset="gb2312" /> <title& ...

  2. CentOS搭建OpenVPN服务(简易版)

    OpenVPN服务端配置 1. 安装OpenVPN软件包 默认的Centos软件源里面没有OpenVPN的软件包,我们可以添加rpmforge的repo,从而实现yum安装openvpn 针对Cent ...

  3. RandomAccessFile类的使用(随机读取java中的文件)

    package coreJava; import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; ...

  4. 批处理:遍历输出指定后缀格式的文件名.bat

    批处理:遍历输出指定后缀格式的文件名.bat @echo off type nul >C:\result.txt for /r "d:\我的文档\桌面\交接\webservice\We ...

  5. 对C语言中sizeof细节的三点分析

    转自对C语言中sizeof细节的三点分析 1.sizeof是运算符,跟加减乘除的性质其实是一样的,在编译的时候进行执行,而不是在运行时才执行. 那么如果编程中验证这一点呢?ps:这是前两天朋友淘宝面试 ...

  6. 0xc0000428 winload.exe无法验证其数字签名的解决方法

    只要把windows/system32/boot中的winload.exe复制到windows/system32中替换即可!! 只有启动画面会有变化,可以使用魔方等软件进行修复,恢复到之前的样子

  7. HDU1632+半平面交

    模板题 题意:给定两个凸多边形,求出合并后的面积,这个合并后的面积不包括重叠部分. #include<stdio.h> #include<string.h> #include& ...

  8. HDU4525+公式

    一开始TLE了... /* 模拟 */ #include<stdio.h> #include<math.h> ; typedef __int64 int64; int64 a[ ...

  9. Hibernate 一对多自身双向关联关系 用于类别表的实现

    分类:一对多自身双向关联关系 Java持久化类: package com.hyy.hibernate.one_to_many.domain; import java.util.HashSet; imp ...

  10. laravel route路由,视图和response和filter

    Laravel充分利用PHP 5.3的特性,使路由变得简单并富于表达性.这使得从构建API到完整的web应用都变得尽可能容易.路由的实现代码在 application/routes.php 文件. 和 ...