zoukankan      html  css  js  c++  java
  • UISegmetControl

    一、UISegmentControl是一个分段控件,父类是UIControl,内涵数个button,并且都有对应下标index;

     

        NSArray *titles = @[@"护卫队",@"三军仪仗队",@"步兵方队",@"炮兵方队"];

        

        UISegmentedControl  *SegmentedC = [[UISegmentedControl alloc]initWithItems:titles];

        SegmentedC.frame = CGRectMake(20, 40, 335, 40);

        SegmentedC.backgroundColor = [UIColor whiteColor];

        

        //    设置文字颜色

        SegmentedC.tintColor = [UIColor redColor];

        //    [SegmentedC setTintColor:[UIColor whiteColor]];

        

        //    默认选中项

        SegmentedC.selectedSegmentIndex =0;

        

        

        //    修改某项的title

        [SegmentedC setTitle:@"女兵方阵" forSegmentAtIndex:2];

        

        //    指定某项宽度

        [SegmentedC setWidth:100 forSegmentAtIndex:1];

        

        //    设置title  文字大小   颜色

        

        NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:15],NSForegroundColorAttributeName:[UIColor blueColor]};

        NSDictionary *dic1 = @{NSFontAttributeName:[UIFont systemFontOfSize:15],NSForegroundColorAttributeName:[UIColor yellowColor]};

        

        [SegmentedC setTitleTextAttributes:dic forState:UIControlStateNormal];

        [SegmentedC setTitleTextAttributes:dic1 forState:UIControlStateSelected];

        

        //    添加点击事件

        [SegmentedC addTarget:self action:@selector(handleSegmented:) forControlEvents:UIControlEventValueChanged];

        

        

        

        [self.view addSubview:SegmentedC];

        

        

        [SegmentedC release];

  • 相关阅读:
    Leon-ai on WSL
    自动化测试工具
    创建自己的Spring Boot Starter
    Spring Boot内嵌Tomcat session超时问题
    Spring Boot
    Spring Cloud
    Socket编程之Tomcat模拟_采坑汇总
    访问者模式
    模版模式
    策略模式
  • 原文地址:https://www.cnblogs.com/tig666666/p/4802063.html
Copyright © 2011-2022 走看看