/** 设置选择器 */
- (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. 数位DP CF 55D Beautiful numbers

    题目链接 题意:定义"beautiful number"为一个数n能整除所有数位上非0的数字 分析:即n是数位所有数字的最小公倍数的倍数.LCM(1到9)=2520.n满足是252 ...

  2. jquery:closest和parents的主要区别

    closest和parents的主要区别是:1,前者从当前元素开始匹配寻找,后者从父元素开始匹配寻找:2,前者逐级向上查找,直到发现匹配的元素后就停止了,后者一直向上查找直到根元素,然后把这些元素放进 ...

  3. hibernate的@EmbeddedId嵌入式主键详解

    一.前言 在我们的日常开发中,有时候会用到数据库进行设计的时候,采用了复合主键来来保证唯一性,下面介绍一下采用hibernate的@EmbeddedId嵌入式主键. 二.说明 设计一个学生类,包含了三 ...

  4. Leetcode Valid Sudoku

    Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be ...

  5. db2look和db2move详解

    db2look和db2move简单实例 --- 建库create database db_name on filesystem_location using codeset utf-8 territo ...

  6. 一些简单编程练习题P【持续更新】

    Q1.写程序将“Hello World”打印到屏幕. A1. public class Test { public static void main(String[] args) { System.o ...

  7. ZK 页面间参数传递

    1.execution.sendRedirect(url) 当使用方法execution.sendRedirect(url)进行页面跳转时,在url中添加参数:url?test=5: 跳转页面获取参数 ...

  8. Ecshop:后台添加新功能栏目以及管理权限设置

    一.添加菜单项 打开 /admin/includes/inc_menu.php文件(后台框架左边菜单),在最后添加一行如下: $modules['17_other_menu']['sns_list'] ...

  9. 使用数据泵+dblink迁移数据库,适用于本地空间不足的情况

    col name for a40 select name,locks,pins from v$db_object_cache where locks > 0 and pins > 0 an ...

  10. Log4J 配置文件全属性详解

    第一步:加入log4j-1.2.8.jar到lib下. 第二步:在CLASSPATH下建立log4j.properties.内容如下: 1 log4j.rootCategory=INFO, stdou ...