zoukankan      html  css  js  c++  java
  • UISegmentedControl的常用属性和用法

    1.UISegmentControl

    1)先创建一个数组用来存放标题

    NSArray *array = @[@"1",@"2",@"3",nil];

    UISegmentedControl *segmented = [[UISegmentedControl alloc] initWithItems:array];

    [segmented insertSegmentWithTitle:@"3" atIndex:3 animated:NO];

    [segmented removeSegmentAtIndex:3 animated:NO];

    [segmented setImage:[UIImage ImageNamed:@"2.png"] forSegmentAtIndesx:1];

    [segmented setTitle:@"分组1" forSegmentAtIndex:0];

    [segmented setWidth:60 fotSegmentAtIndex:0];

    //UISegmented的点击事件,后面的控制事件的状态一定是valueChanged

    [segmented addTarget:self action:@selector(segmentAction:) forControlEvent:UIControlEventValueChanged];

    2.通常UISegmentedControl的点击事件和switch case结合使用

    - (void)segmentedAction:(UISegmentedControl *)segmented {

      switch (segmented.selectedSegmentIndex) {

      case 0 :

    self.backGroundColor = [UIColor yellowColor];

      break;

      default:

      break;

    }

    }

  • 相关阅读:
    CSAcademy Or Problem
    BZOJ 4516 [Sdoi2016] 生成魔咒
    SPOJ7258 SUBLEX
    SPOJ1812 LCS2
    SPOJ1811 LCS
    SPOJ8222 NSUBSTR
    洛谷3804 【模板】后缀自动机
    SPOJ287 NETADMIN
    SPOJ1693 COCONUTS
    BZOJ5329 SDOI2018 战略游戏
  • 原文地址:https://www.cnblogs.com/arenouba/p/5183622.html
Copyright © 2011-2022 走看看