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. 在sql中使用了 hashbytes 函数

    在做项目的时候,在sql中使用了hashbytes函数,运用md5算法去加密一密码.代码如下 DECLARE @psw nvarchar(20) SET @psw = 'admin' SELECT h ...

  2. [XAF]如何在非按钮事件中打开视图

    private static void OpenDetailView(XafApplication app) { IObjectSpace os = app.CreateObjectSpace(); ...

  3. IAR USING PRE- AND POST-BUILD ACTIONS

    Using pre-build actions for time stamping If necessary, you can specify pre-build and post-build act ...

  4. Ajax的常用框架有哪些?

    AJAX(Asynchronous JavaScript and XML,异步JavaScript和XML),是创建交互式Web应用的主要开发技术.互联网中也有大量的关于AJAX的框架,本文汇总了最常 ...

  5. 一分钟制作U盘版BT3 - 有图滴儿 bt3破解教程

    一分钟制作 BT3 U盘版方便,快捷简单无效不退款 光盘版BT3, 大概694MB,直接刻盘,然后用光盘引导,就可以进入bt3,连接为:http://ftp.heanet.ie/mirrors/bac ...

  6. C++ Primer 学习笔记_46_STL实践与分析(20)--容器特有的算法

    STL实践与分析 --容器特有的算法 与其它顺序容器所支持的操作相比,标准库为list容器定义了更精细的操作集合,使它不必仅仅依赖于泛型操作.当中非常大的一个原因就是list容器不是依照内存中的顺序进 ...

  7. CSS3+Js制作的一款响应式导航条

    今天制作了一个响应式导航条,能够自动随着不同的屏幕分辨率或浏览器窗口大小的不同而改变导航条的样式,这里主要用到的就是CSS3的Media Query.具体可以查看浅谈响应式布局这篇文章,这里就不花费大 ...

  8. 你已经毁了JavaScript

    以前 过去我们在页面上用很时尚的方式写了一些确实很可怕的代码,它给我们带来了巨大的麻烦.可能很多人现在还在这样做,但他们不会看这篇博文,我们可以假装他们不存在. JS的伟大/了不起/让人惊讶的地方在于 ...

  9. IOS 7 Study - Displaying an Image on a Navigation Bar

    ProblemYou want to display an image instead of text as the title of the current view controlleron th ...

  10. Codeforces Round #188 (Div. 2) B. Strings of Power 水题

    B. Strings of Power Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/318/p ...