UISegmentedControl 的使用
/** 设置选择器 */
- (void)setUpSegmentCtr {
UISegmentedControl *segmentCtr = [[UISegmentedControl alloc] initWithItems:@[@"采购订单",@"销售订单"]];
self.navigationItem.titleView = segmentCtr;
[segmentCtr addTarget:self action:@selector(didClicksegmentedControlAction:) forControlEvents:UIControlEventValueChanged];
self.segmentCtr = segmentCtr;
NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:EMCNavColor,
NSForegroundColorAttributeName,
[UIFont boldSystemFontOfSize:],
NSFontAttributeName,nil]; [ self.segmentCtr setTitleTextAttributes:dic forState:UIControlStateSelected]; NSDictionary* unselectedTextAttributes = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:],
NSForegroundColorAttributeName: [UIColor whiteColor]};
[self.segmentCtr setTitleTextAttributes:unselectedTextAttributes forState:UIControlStateNormal]; [self.segmentCtr setBackgroundImage:[UIImage imageWithColor:[UIColor clearColor]] forState:UIControlStateNormal barMetrics:UIBarMetricsDefaultPrompt];
[self.segmentCtr setBackgroundImage:[UIImage imageWithColor:[UIColor whiteColor]] forState:UIControlStateSelected barMetrics:UIBarMetricsDefaultPrompt]; self.segmentCtr.tintColor = [UIColor whiteColor];
self.segmentCtr.apportionsSegmentWidthsByContent = NO;
self.segmentCtr.backgroundColor = [UIColor clearColor];
self.segmentCtr.selectedSegmentIndex = ;
}
再viewdidload中添加
- (void)viewDidLoad {
[super viewDidLoad];
/** 设置选择器 */
[self setUpSegmentCtr];
}
效果图如下:

UISegmentedControl 的使用的更多相关文章
- iOS在导航栏上居中显示分段控件(UISegmentedControl)
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:nil]; segmentedCont ...
- 【UISegmentedControl】- 分段控件
一.初始化 二.常见的属性 1.segmentedControlStyle属性:设置基本的样式 2.momentary属性:设置在点击后是否恢复原样 . 3.numberOfSegments属性:只读 ...
- UI控件(UISegmentedControl)
@implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; NSArray* segmentArray = [[ ...
- UI第八节——UISegmentedControl
- (void)viewDidLoad { [super viewDidLoad]; NSArray *items = @[@"消息", @"电话" ...
- UISegmentedControl和UIStepper的使用
UISegmentedControl:分栏控件,常用的属性和方法是 1.tintColor:控制分栏控件的颜色风格 2.insertSegmentWithTitle(Image):插入分栏标题(图片) ...
- UISegmentedControl 控件
一.创建 UISegmentedControl* mySegmentedControl = [[UISegmentedControl alloc]initWithItems:nil]; 是不是很奇怪没 ...
- UI中一些不常用的控件UIActivityIndicatorView、UIProgressView、UISegmentedControl、UIStepper、UISwitch、UITextView、UIAlertController
//UIActivityIndicatorView //小菊花,加载 #import "ActivityIndicatorVC.h" @interface ActivityIndi ...
- UISegmentedControl(人物简介)
效果图 当你点击上面人物名字的时候 ,就可以随意切换人物. 这个很有趣 , 你还可以试着添加音乐播放器 .以及一些别的来完善你想做的. 好吧 , 废话不多说 , 上代码. #import " ...
- UILabel UISwitch UISegmentedControl UIAlertView
基础小控件 /***************************************UIlabel*************************************/ UILabel ...
随机推荐
- Fzu2124 - 吃豆人 BFS
Description 吃豆人是一款非常经典的游戏,游戏中玩家控制吃豆人在地图上吃光所有豆子,并且避免被怪物抓住. 这道题没有怪物,将游戏的画面分成n*m的格子,每格地形可能为空地或者障碍物,吃豆人可 ...
- 转:AngularJS的Filter用法详解
Filter简介 Filter是用来格式化数据用的. Filter的基本原型( '|' 类似于Linux中的管道模式): {{ expression | filter }} Filter可以被链式使用 ...
- Java知识结构
- ZeroMQ接口函数之 :zmq_unbind - 停止连接外来的请求
ZeroMQ 官方地址 :http://api.zeromq.org/4-2:zmq_unbind zmq_unbind(3) ØMQ Manual - ØMQ/4.1.0 Name zmq_unbi ...
- phpcmsv9 阿里云OSS云存储整合教程
该教程算不上是phpcmsv9阿里云oss插件,所以整个修改及其代码覆盖前请一定记得备份.还有一点就是后台发布文章时上传的附件还是会保存在你的服务器上,基于以下原因:1.个人的需求是前台页面需要使用t ...
- PHP静态化
一.判断大型网站的标准 1.pv值(page views)网站浏览量: 概念:一个网站,所有的页面,在一天24小时内,被访问的总量,达到千万级别,或者几百万以上. 2.uv值(unique visit ...
- mysql cpu和内存监控
mysqlMem 监控:#!/bin/bashPid=`/bin/ps -ef|grep mysqld|grep -Ev "grep|safe"|awk '{print $2}'` ...
- linux中test与[ ]指令的作用
linux中test与[ ]指令的作用: 在Linux中,test和[ ]功能是一样的,类似于c语言中的( ).不过Linux的test和[ ]是指令.在和if或者while联用时要用空格分开.
- IOS ReactiveCocoa
一 前提: 在iOS开发过程中,当某些事件响应时,需处理的某些业务逻辑 Eg. 按钮点击:action ScrollView滚动:delegate 属性值改变:KVO ReactiveCocoa为事件 ...
- linux引导流程
本章重点: 1.linux引导流程 2.linux运行级别 3.linux启动服务管理 4.GRUB配置与应用 5.启动故障分析解决 linux启动流程 1.固件(fireware):固话在硬件上的程 ...