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

    }

  • 相关阅读:
    Linux服务器通过rz/sz轻松上传下载文件
    Linux卸载系统自带的JDK
    汉语-词语:恒等
    汉语-词语:女人
    汉语-词语:长远
    汉语-词语:长久
    汉语-词语:短暂
    汉语-词语:当下
    汉语-词语:漫长
    中药:小麦
  • 原文地址:https://www.cnblogs.com/sunfuyou/p/5952687.html
Copyright © 2011-2022 走看看