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

  • 相关阅读:
    tensorflow入门笔记(五) name_scope和variable_scope
    tensorflow入门笔记(四) tf.summary 模块
    tensorflow入门笔记(三) tf.GraphKeys
    tensorflow入门笔记(二) 滑动平均模型
    tensorflow入门笔记(一) tf.app.flags.FLAGS
    iOS友盟推送注意点
    关于gif图片重用消失问题。
    百度地图使用经验
    SQLite语句
    app登录,client和serve的常用字段。
  • 原文地址:https://www.cnblogs.com/tig666666/p/4802063.html
Copyright © 2011-2022 走看看