zoukankan      html  css  js  c++  java
  • ios UISegmentedControl 用法举例

    UISegmentedControl * segmentControl = [[UISegmentedControl alloc]initWithFrame:CGRectMake(0, 0, 160, 30)];

    segmentControl.tintColor = kMainOrangeColor;

    [segmentControl insertSegmentWithTitle:@"XX" atIndex:0 animated:NO];

    [segmentControl insertSegmentWithTitle:@"XX" atIndex:1 animated:NO];

    segmentControl.selectedSegmentIndex = 0;

    //    [segmentControl setTitle:@"关注" forSegmentAtIndex:0];

    //    [segmentControl setTitle:@"订阅" forSegmentAtIndex:1];

    self.navigationItem.titleView = segmentControl;

    //设置普通状态下(未选中)状态下的文字颜色和字体

    //    [self.segmentedControl setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12],NSForegroundColorAttributeName: [UIColor blackColor]} forState:UIControlStateNormal];

    //设置选中状态下的文字颜色和字体

    //    [self.segmentedControl setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName: [UIColor blackColor]} forState:UIControlStateSelected];

    //添加监听

    [segmentControl addTarget:self action:@selector(sementedControlClick:) forControlEvents:UIControlEventValueChanged];

    //监听方法

    - (void)sementedControlClick:(UISegmentedControl *)controlllll{

        NSLog(@"%lu ",controlllll.selectedSegmentIndex);

        

    }

  • 相关阅读:
    mysql 大数据量求平均值
    mysql 大数据量求平均值
    dhcpd.conf(5)
    dhcpd.conf(5)
    学习记录(文章内容来自相关材料)
    分享一个ASP.NET 文件压缩解压类 C#
    服务降级
    distinct用法
    trim合理和谐
    小娱乐一下,fileInfo中的Name ,FullName的用法小BUG
  • 原文地址:https://www.cnblogs.com/isItOk/p/4873154.html
Copyright © 2011-2022 走看看