1、UISegmentedControl

NSArray * array = @[@"red",@"green",@"yellow",@"blue",@"orange"];

//分段选择器

UISegmentedControl * segment = [[UISegmentedControl alloc] initWithItems:array];

segment.frame = CGRectMake(20, CGRectGetHeight(self.view.frame) - 100, CGRectGetWidth(self.view.frame) - 40, 30);

//是否能选中

segment.momentary = NO;

//文字适应宽度

segment.apportionsSegmentWidthsByContent = NO;

//根据索引插入数据

//    [segment insertSegmentWithTitle:@"apple" atIndex:1 animated:YES];

//    [segment setImage:[UIImage imageNamed:@"onimage"] forSegmentAtIndex:2];

segment.tintColor = [UIColor orangeColor];

[segment addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];

[self.view addSubview:segment];

}

- (void)segmentAction:(UISegmentedControl *)segment {

NSInteger index = segment.selectedSegmentIndex;

switch (index) {

case 0:

self.view.backgroundColor = [UIColor redColor];

break;

case 1:

self.view.backgroundColor = [UIColor greenColor];

break;

case 2:

self.view.backgroundColor = [UIColor yellowColor];

break;

case 3:

self.view.backgroundColor = [UIColor blueColor];

break;

case 4:

self.view.backgroundColor = [UIColor orangeColor];

break;

default:

break;

}

}

 

iOS - UI - UISegmentedControl的更多相关文章

  1. [IOS]IOS UI指南

    [IOS]IOS UI指南 众所周知,IOS的界面设计,越来越流行,可以说都形成了一个标准,搜集了一些资料,供自己以后学习使用! iOS Human Interface Guidelines (中文翻 ...

  2. IOS UI 第八篇:基本UI

    实现图片的滚动,并且自动停止在每张图片上     - (void)viewDidLoad{    [super viewDidLoad]; UIScrollView *scrollView = [[U ...

  3. 国外IOS UI指南

    国外IOS UI指南 众所周知,IOS的界面设计,越来越流行,可以说都形成了一个标准,搜集了一些资料,供自己以后学习使用! iOS Human Interface Guidelines (中文翻译) ...

  4. iOS UI的几种模式

    iOS UI的几种模式: 1.平凡模式(原生控件组合): 2.新闻模式: 3.播放器模式: 4.微博模式:

  5. 通过实现一个TableView来理解iOS UI编程

    推荐一篇神作: 通过实现一个TableView来理解iOS UI编程 http://blog.jobbole.com/61101/

  6. IOS UI segmentedControl UISegmentedControl 常见属性和用法

    UISegmentedControl中一些常见的属性和用法 //设置以图案作为分段的显示,仅需要图案的轮廓,这样颜色为分段的背景颜色 //    NSArray *items = @[[UIImage ...

  7. [iOS UI设计笔记整理汇总]

    8.UIsearchbar放到Navigationbar 上(意思是建个View作为titleview) //此处调用的是第三方封装的SearchBar,也可以自定义. self.searchBarW ...

  8. iOS UI高级之网络编程(HTTP协议)

    HTTP协议的概念 HTTP协议,Hyper Text Transfer Protocol (超文本传输协议)是用于从万维网服务器传送超文本到本地浏览器的传输协议,HTTP是一个应用层协议,由请求和响 ...

  9. iOS - UI - UIWebView

    1.UIWebView UIWebView 是 苹果提供的用来展示网页的UI控件.它也是最占内存的控件. iOS8.0 webkit框架. WKWebView,相比UIWebView,节省了1/3~1 ...

随机推荐

  1. poj1061 青蛙的约会 扩展欧几里德的应用

    这个题解得改一下,开始接触数论,这道题目一开始是看了别人的思路做的,后来我又继续以这种方法去做题,发现很困难,学长告诉我先看书,把各种词的定义看懂了,再好好学习,我做了几道朴素的欧几里德,尽管是小学生 ...

  2. webservice接口的发布

    使用xfire-client发布webservice接口: commons-codec-1.3.jar commons-httpclient-3.0.jar 在src 下创建META-INF/xfir ...

  3. JavaScript寻踪OOP之路

    上一集中,重点介绍了谁动了你的代码.这里先总结一下:咱们的代码从敲下来到运行出结果,经历了两个阶段:分析期与运行期.在分析期,JavaScript分析器悄悄动了我们的代码:在运行期,JavaScrip ...

  4. EXTJS中的grid显示实际行号

    添加一个新的功能 Ext.grid.PageRowNumberer = Ext.extend(Ext.grid.RowNumberer, { width : 40, renderer:function ...

  5. Google Chrome浏览器调试功能介绍

    作为Web开发人员,我为什么喜欢Google Chrome浏览器 [原文地址:http://www.cnblogs.com/QLeelulu/archive/2011/08/28/2156402.ht ...

  6. 在sphinx中应用复杂过滤条件

    一.问题的引入   在sphinx应用中,需要对数据进行复杂的条件过滤,刷选出我们需要的数据.这个过程,等同于mysql查询中的where条件.   但sphinx本身的filter并不能支持复杂的逻 ...

  7. ubuntu12.04_64bit adb shell

    1.#adb shell 提示error: insufficient permissions for device 解决办法: 1)sudo gedit /etc/udev/rules.d/51-an ...

  8. POJ 3006 Dirichlet's Theorem on Arithmetic Progressions 快筛质数

    题目大意:给出一个等差数列,问这个等差数列的第n个素数是什么. 思路:这题主要考怎样筛素数,线性筛.详见代码. CODE: #include <cstdio> #include <c ...

  9. 使用jQuery Mobile和Phone Gap开发Android应用程序

    经过了一段时间的学习,初步了解了该如何使用jQuery Mobile和 Phone Gap来开发一个Android应用程序,也想把这些东西介绍给大家. 1. 软件准备 要进行android app的开 ...

  10. Codeforces Educational Codeforces Round 3 B. The Best Gift 水题

    B. The Best Gift 题目连接: http://www.codeforces.com/contest/609/problem/B Description Emily's birthday ...