zoukankan      html  css  js  c++  java
  • iosUISegmentedControl的基本设置

     //创建segmentControl 分段控件

        UISegmentedControl *segC = [[UISegmentedControl alloc]initWithFrame:CGRectMake(50, 100, 200, 30)];

        //添加小按钮

        [segC insertSegmentWithTitle:@"左边" atIndex:0 animated:YES];

        [segC insertSegmentWithTitle:@"中间" atIndex:1 animated:YES];

        [segC insertSegmentWithTitle:@"右边" atIndex:2 animated:YES];

        //设置样式

        [segC setTintColor:[UIColor grayColor]];

    //self.segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;

       // self.segmentedControl.tintColor = [UIColor whiteColor];

        //设置字体样式

        [segC setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:[UIColor redColor]} forState:UIControlStateNormal];

        //添加事件

        [segC addTarget:self action:@selector(segCChanged:) forControlEvents:UIControlEventValueChanged];

        

        

        [self.view addSubview:segC];

        

    }

    -(void)segCChanged:(UISegmentedControl *)seg

    {

        NSInteger i = seg.selectedSegmentIndex;

        NSLog(@"切换了状态 %lu",i);

    }

  • 相关阅读:
    ConcurrentHashMap源码阅读
    java中Scanner类nextLine()和next()的区别和使用方法
    setuid
    lsattr
    设置umask
    touch
    od
    vi 搜索
    nl
    cat 参数
  • 原文地址:https://www.cnblogs.com/sunfuyou/p/5952687.html
Copyright © 2011-2022 走看看