IOS7UISlider/UIProgressView/UISwitch/UISegmentedControl

来源:互联网 发布:c语言是怎么开发出来的 编辑:程序博客网 时间:2024/05/18 01:16
    //slider image can be changed
    UISlider *slider = [[UISlider alloc]initWithFrame:CGRectMake(10, 100, 100, 30)];
    slider.value = 0.0f;
    [self.view addSubview:slider];
    
    //switch image can be changed
    UISwitch *mSwitch = [[UISwitch alloc]initWithFrame:CGRectMake(10, 150, 100, 40)];
    self.navigationItem.titleView = mSwitch;
    //[self.view addSubview:mSwitch];

   


    UISegmentedControl *segmentControl = [[UISegmentedControl alloc]initWithItems:nil];   
    segmentControl.frame = CGRectMake(150, 150, 200, 30);
    [segmentControl insertSegmentWithTitle:@"1" atIndex:0 animated:true];
    
    [segmentControl insertSegmentWithTitle:@"2" atIndex:1 animated:true];
    
    [segmentControl addTarget:self action:@selector(segmentcallback:) forControlEvents:UIControlEventValueChanged];
    
    [segmentControl setWidth:20.0f forSegmentAtIndex:0];
    [segmentControl setWidth:20.0f forSegmentAtIndex:1];
    [segmentControl setTintColor:[UIColor greenColor]];
    [self.view addSubview:segmentControl];

   

    UIProgressView *progressview = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleDefault];   
    progressview.progress = 0.5f;
    progressview.tintColor = [UIColor greenColor];
    progressview.frame = CGRectMake(100, 100, 200, 30);
    [self.view addSubview:progressview];