zoukankan      html  css  js  c++  java
  • iOS开篇——UI之UISegmentedControl (分段选择器)

    创建分段选择器

        UISegmentedControl * sc = [[UISegmentedControl alloc]initWithFrame:CGRectMake(50, 100, 200, 30)];
        
        [sc insertSegmentWithTitle:@"第一页" atIndex:0 animated:YES];
        [sc insertSegmentWithTitle:@"第二页" atIndex:1 animated:YES];
        [sc insertSegmentWithTitle:@"第三页" atIndex:2 animated:YES];
        
        [sc addTarget:self action:@selector(onClick:) forControlEvents:UIControlEventValueChanged];
    
        [self.view addSubview:sc]; 

    实现点击方法

    - (void)onClick:(UISegmentedControl *)sc {
        if (sc.selectedSegmentIndex == 0) {
            [sc removeSegmentAtIndex:0 animated:YES];
        }else if(sc.selectedSegmentIndex == 1){
            [sc insertSegmentWithTitle:@"礼拜" atIndex:0 animated:YES];
        }
    }
    //根据传来的sc的index值判断执行的方法
  • 相关阅读:
    leetcode-- 79. Word Search
    Zuul 网关
    Feign
    Hystrix 熔断器
    Ribbon
    Spring-Cloud Eureka
    JacksonJson的使用
    springboot 常见的启动器
    axiso 的使用
    Java含有Date的对象序列化网络传输
  • 原文地址:https://www.cnblogs.com/gwkiOS/p/4990251.html
Copyright © 2011-2022 走看看