zoukankan      html  css  js  c++  java
  • 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:14],
                             NSFontAttributeName,nil];
        
        [ self.segmentCtr setTitleTextAttributes:dic forState:UIControlStateSelected];
        
        NSDictionary* unselectedTextAttributes = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:14],
                                                   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 = 0;
    }

    再viewdidload中添加

    - (void)viewDidLoad {
        [super viewDidLoad];
        
        /** 设置选择器 */
        [self setUpSegmentCtr];
        
    }

    效果图如下:

  • 相关阅读:
    Django
    C++开源库集合
    单细胞参考文献 single cell
    第三章 RNA测序
    第二章 基因芯片
    前言 转录组
    生物信息学——RNA的剪切过程
    生信研究内容
    测序总结,高通量测序名词
    单端测序,双端测序,基因组计划图谱
  • 原文地址:https://www.cnblogs.com/lyz0925/p/6101104.html
Copyright © 2011-2022 走看看