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);

        

    }

  • 相关阅读:
    python+appium真机运行登录例子
    通过aapt查看apk包名和第一个启动的activity
    cf 17D Notepad 欧拉降幂
    主席树入门
    D2. Optimal Subsequences (Hard Version) 主席树
    cf 697C Lorenzo Von Matterhorn 思维
    2018南京现场赛K 随机输出
    2018徐州现场赛A
    洛谷p1137 模拟退火
    2018南京现场赛D 模拟退火
  • 原文地址:https://www.cnblogs.com/isItOk/p/4873154.html
Copyright © 2011-2022 走看看