zoukankan      html  css  js  c++  java
  • UISegmentedControl的基本使用

      // 创建一个数组

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

        // 创建UISegmentedControl

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

        segmentedcontrol.frame = CGRectMake(50, 50, 200, 50);

        // 设置默认选项

        segmentedcontrol.selectedSegmentIndex = 0;

      // 设置字体颜色

        segmentedcontrol.tintColor = [UIColor blueColor];

     // 点击后恢复原样

        segmentedcontrol.momentary = YES;

     // 设置标题文字

        [segmentedcontrol setTitle:@"0" forSegmentAtIndex:0];

       // 插入标题文字

        [segmentedcontrol insertSegmentWithTitle:@"0" atIndex:0 animated:YES];

       // 删除单个标题文字

        [segmentedcontrol removeSegmentAtIndex:0 animated:YES];

     // 删除全部标题文字

        [segmentedcontrol removeAllSegments];

     // 获得被选中的标题文字

        NSString *str = [segmentedcontrol titleForSegmentAtIndex:0];

     // 设置该索引的宽度

        [segmentedcontrol setWidth:50 forSegmentAtIndex:0];

     // 设置该索引的外边距

        [segmentedcontrol setContentOffset:CGSizeMake(10, 10) forSegmentAtIndex:0];

     // 判断改索引能否被点击

        [segmentedcontrol setEnabled:YES forSegmentAtIndex:0];

     // 设置segmentedcontrol的背景图片

        [segmentedcontrol setBackgroundImage:image forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

  • 相关阅读:
    SQL语句熟悉
    CSS3 attribute
    轮播器
    PHP 邮箱操作的Action
    Hole puncher Show Picture
    力扣算法——133.CloneGraph【M】
    力扣算法——134GasStation【M】
    力扣算法——135Candy【H】
    力扣算法——136SingleNumber【E】
    力扣算法——137SingleNumberII【M】
  • 原文地址:https://www.cnblogs.com/enback/p/3826413.html
Copyright © 2011-2022 走看看