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;

    }

    }

  • 相关阅读:
    【游戏开发】Excel表格批量转换成CSV的小工具
    iOS
    iOS
    Xcode
    iOS
    iOS
    iOS
    iOS
    iOS
    iOS
  • 原文地址:https://www.cnblogs.com/arenouba/p/5183622.html
Copyright © 2011-2022 走看看