/** 设置选择器 */
- (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 的使用的更多相关文章

  1. iOS在导航栏上居中显示分段控件(UISegmentedControl)

    UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:nil]; segmentedCont ...

  2. 【UISegmentedControl】-  分段控件

    一.初始化 二.常见的属性 1.segmentedControlStyle属性:设置基本的样式 2.momentary属性:设置在点击后是否恢复原样 . 3.numberOfSegments属性:只读 ...

  3. UI控件(UISegmentedControl)

    @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; NSArray* segmentArray = [[ ...

  4. UI第八节——UISegmentedControl

    - (void)viewDidLoad {    [super viewDidLoad];    NSArray *items = @[@"消息", @"电话" ...

  5. UISegmentedControl和UIStepper的使用

    UISegmentedControl:分栏控件,常用的属性和方法是 1.tintColor:控制分栏控件的颜色风格 2.insertSegmentWithTitle(Image):插入分栏标题(图片) ...

  6. UISegmentedControl 控件

    一.创建 UISegmentedControl* mySegmentedControl = [[UISegmentedControl alloc]initWithItems:nil]; 是不是很奇怪没 ...

  7. UI中一些不常用的控件UIActivityIndicatorView、UIProgressView、UISegmentedControl、UIStepper、UISwitch、UITextView、UIAlertController

    //UIActivityIndicatorView //小菊花,加载 #import "ActivityIndicatorVC.h" @interface ActivityIndi ...

  8. UISegmentedControl(人物简介)

    效果图 当你点击上面人物名字的时候 ,就可以随意切换人物. 这个很有趣 , 你还可以试着添加音乐播放器 .以及一些别的来完善你想做的. 好吧 , 废话不多说 , 上代码. #import " ...

  9. UILabel UISwitch UISegmentedControl UIAlertView

    基础小控件 /***************************************UIlabel*************************************/ UILabel ...

随机推荐

  1. Xcode 插件失效

    1.终端输入: 如果放在了应用程序里,就是这个: defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityU ...

  2. JQuery上传插件Uploadify使用详解

    本文转载http://www.cnblogs.com/oec2003/archive/2010/01/06/1640027.html Uploadify是JQuery的一个上传插件,实现的效果非常不错 ...

  3. Nagios配置文件详解

    首先要看看目前Nagios的主配置路径下有哪些文件.[root@nagios etc]# ll总用量 152-rwxrwxr-x. 1 nagios nagios 1825 9月  24 14:40 ...

  4. BZOJ4078 : [Wf2014]Metal Processing Plant

    设$D(A)\leq D(B)$,从小到大枚举$D(A)$,双指针从大到小枚举$D(B)$. 那么对于权值不超过$D(A)$的边,可以忽略. 对于权值介于$(D(A),D(B)]$之间的边,需要满足那 ...

  5. T-SQL Recipes之生成动态列表数据

    Problem 首先什么是动态列表?举个示例,假设你想输出以逗号分隔的IDs,如: 1,45,67,199,298 Solution 生成动态列表数据在我们生活场景中很常见,比如在 Dynamic P ...

  6. asp.net三层架构详解

    一.数据库 /*==============================================================*/ /* DBMS name:      Microsof ...

  7. 2016 CCPC长春重现赛

    1.2016中国大学生程序设计竞赛(长春)-重现赛 2.总结:会做的太少,应变能力也不行,或者说猜题目的能力不行 02  水 04  HDU 5914  Triangle 1.题意:1~n,n个数,问 ...

  8. Hive_数据倾斜处理

    Hive中三种join map join (小表join大表,将小表加入到内存) 设置map join: hive.auto.convert.join=true hive.mapjoin.smallt ...

  9. MySQL索引简述

    文章归属:http://feiyan.info/16.html,我想自己总结,但是发现此君总结的非常详细.直接搬过来了 关于MySQL索引的好处,如果正确合理设计并且使用索引的MySQL是一辆兰博基尼 ...

  10. Android课程---添加黑名单的练习2(课堂讲解)

    实现黑名单的添加.修改.查询和删除,首先得有封装的3个类,便于使用 BlackNumber.java package com.hanqi.test3; /** * Created by Adminis ...