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. Codeforces Round #292 (Div. 1) B. Drazil and Tiles (类似拓扑)

    题目链接:http://codeforces.com/problemset/problem/516/B 一个n*m的方格,'*'不能填.给你很多个1*2的尖括号,问你是否能用唯一填法填满方格. 类似t ...

  2. UVaLive 6602 Counting Lattice Squares (找规律)

    题意:给定一个n*m的矩阵,问你里面有几面积为奇数的正方形. 析:首先能知道的是,大的矩阵是包括小的矩阵的,而且面积为奇数,我们只要考虑恰好在边界上的正方形即可,画几个看看就知道了,如果是3*3的有3 ...

  3. 在VSTO界面中,调用xll中的函数

    最近研究各种有点迷茫了,原来Xll的加载宏直接可以在C#中调用的,我又各种Out了. 先说明一下,在VBA中,如何调用吧 XLLFound = Application.RegisterXLL(This ...

  4. IIS6.0禁止用户下载txt文件

    服务器win2003+IIS6.0,在IIS上限制下载.txt文件,方法比较简单,在IIS的应用程序扩展名映射中为资源扩展名指定一个错误的可执行文件即可. 打开记事本,直接将空内容保存为C:\WIND ...

  5. window.print打印指定div

    window.print可以打印网页,但有时候我们只希望打印特定控件或内容,怎么办呢? 首先我们可以把要打印的内容放在div中,然后用下面的代码进行打印. <html> <head& ...

  6. Tun/Tap interface tutorial

    Foreword: please note that the code available here is only for demonstration purposes. If you want t ...

  7. CSS Layout

    fontline-heightcolormarginpaddingbordertext-alignbackground widthheightfloatcleardisplay 定位属性 属 性 描 ...

  8. START167 AND BOOT167

    http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka10535.html C166: START167 AND BOO ...

  9. Windows Server 2003下ASP.NET无法识别IE11的解决方法

    由于IE11对User-Agent字符串进行了比较大的改动,所以导致很多通过User-Agent来识别浏览器的程序,都相应的出现了无法识别IE11的情况.(普通用户端则可以通过这个方法来进行设置.) ...

  10. 怎样解决VirtrualBox不能新建64bit的系统的问题

    假设你的VirtrualBox不能新建64bit的虚拟机一般有以下两个原因: 1.电脑是32位的,不支持创建64bit的虚拟机 2.电脑不支持Intel VT-x,或者是Intel VT-x没有打开 ...