UI基础控件的使用1

来源:互联网 发布:移动数据开关已关闭 编辑:程序博客网 时间:2024/05/21 22:33

//

//  ViewController.m

// UI基础控件的使用1

//

//  Created by 唐帅 on 15/12/3.

//  Copyright ? 2015年 tang. All rights reserved.

//

 

#import "ViewController.h"

 

@interface ViewController ()

 

@property (weaknonatomicIBOutlet UISwitch *LeftSwich;

 

@property (weaknonatomicIBOutlet UISwitch *RightSwitch;

@property (weaknonatomicIBOutlet UILabel *lblShow;

- (IBAction)btnOK:(id)sender;

 

- (IBAction)sliderValueChange:(id)sender;

- (IBAction)touchDown:(id)sender;

 

@end

 

@implementation ViewController

 

- (void)viewDidLoad {

    [super viewDidLoad];

 

  

}

 

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

 

}

 

//开关控件的使用

-(IBAction)sWtichValueChanged:(id)sender{

    UISwitch *witchSwitch=(UISwitch *)sender;

    BOOL setting=witchSwitch.isOn;

    [self.LeftSwich setOn:setting animated:YES];

    [self.RightSwitch setOn:setting animated:YES];

}

 

    - (IBAction)btnOK:(id)sender {

       

    }

//滑块的使用

- (IBAction)sliderValueChange:(id)sender {

   

    UISlider *slider=(UISlider *)sender;

    int progressAsInt=(int)slider.value;

    NSString *newText=[[NSStringalloc]initWithFormat:@"%d",progressAsInt];

    self.lblShow.text=newText;

   

   

}

 

 

// 分段空间的使用方法

- (IBAction)touchDown:(id)sender {

    if(self.LeftSwich.hidden==YES)

    {

//        左右开关空间都隐藏

        self.RightSwitch.hidden=NO;

        self.LeftSwich.hidden=NO;

    }

    else

    {

//        左右开关空间都显示

        self.RightSwitch.hidden=YES;

        self.LeftSwich.hidden=YES;

    }

}

@end


0 0
原创粉丝点击