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

  • 相关阅读:
    Eclipse 如何安装反编译插件
    java下执行mongodb
    如何利用Xshell在Linux下安装jdk
    asp.net signalR
    手机抓包 fiddler magicwifi
    NServiceBus 消息
    .net 异步函数 Async await
    .net 任务(Task)
    .net 线程基础 ThreadPool 线程池
    .net 序列化反序列化
  • 原文地址:https://www.cnblogs.com/enback/p/3826413.html
Copyright © 2011-2022 走看看