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

  • 相关阅读:
    思念
    空白
    curl json string with variable All In One
    virtual scroll list All In One
    corejs & RegExp error All In One
    socket.io All In One
    vue camelCase vs PascalCase vs kebabcase All In One
    element ui 表单校验,非必填字段校验 All In One
    github 定时任务 UTC 时间不准确 bug All In One
    input range & color picker All In One
  • 原文地址:https://www.cnblogs.com/enback/p/3826413.html
Copyright © 2020-2023  润新知