zoukankan      html  css  js  c++  java
  • ios UISegmentedControl 用法举例

    UISegmentedControl * segmentControl = [[UISegmentedControl alloc]initWithFrame:CGRectMake(0, 0, 160, 30)];

    segmentControl.tintColor = kMainOrangeColor;

    [segmentControl insertSegmentWithTitle:@"XX" atIndex:0 animated:NO];

    [segmentControl insertSegmentWithTitle:@"XX" atIndex:1 animated:NO];

    segmentControl.selectedSegmentIndex = 0;

    //    [segmentControl setTitle:@"关注" forSegmentAtIndex:0];

    //    [segmentControl setTitle:@"订阅" forSegmentAtIndex:1];

    self.navigationItem.titleView = segmentControl;

    //设置普通状态下(未选中)状态下的文字颜色和字体

    //    [self.segmentedControl setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12],NSForegroundColorAttributeName: [UIColor blackColor]} forState:UIControlStateNormal];

    //设置选中状态下的文字颜色和字体

    //    [self.segmentedControl setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName: [UIColor blackColor]} forState:UIControlStateSelected];

    //添加监听

    [segmentControl addTarget:self action:@selector(sementedControlClick:) forControlEvents:UIControlEventValueChanged];

    //监听方法

    - (void)sementedControlClick:(UISegmentedControl *)controlllll{

        NSLog(@"%lu ",controlllll.selectedSegmentIndex);

        

    }

  • 相关阅读:
    Vue--会员管理列表页面,抽取BASE_URL
    Vue--系统权限拦截
    写译-冲刺班
    看到一篇有收获的博文【关于外挂生涯的忠告】(转载)
    笔记管理-vscode-印象笔记-git-博客园
    1.4条件和循环
    1.3撰写表达式
    1.2对象定义与初始化
    1.1如何写一个c++程序
    send()函数 recv()函数
  • 原文地址:https://www.cnblogs.com/isItOk/p/4873154.html
Copyright © 2011-2022 走看看