CheckBox选择框

来源:互联网 发布:网络摄像头直接接电脑 编辑:程序博客网 时间:2024/05/21 19:25
#import "EFSelectGasViewController.h"@interface EFSelectGasViewController ()@property (weak, nonatomic) IBOutlet UIButton *confromBtn;@property (weak, nonatomic) IBOutlet UILabel *firstLabel;@property (weak, nonatomic) IBOutlet UILabel *secondLabel;@property (weak, nonatomic) IBOutlet UILabel *thirdLabel;@property (weak, nonatomic) IBOutlet UILabel *forthLabel;@property (weak, nonatomic) IBOutlet UIButton *firstCheckBox;@property (weak, nonatomic) IBOutlet UIButton *secondCheckBox;@property (weak, nonatomic) IBOutlet UIButton *thirdCheckBox;@property (weak, nonatomic) IBOutlet UIButton *forthCheckBox;@property (weak, nonatomic) IBOutlet UITextField *gasNumTextField;@property (nonatomic, strong) NSArray *items;- (IBAction)confromBtnClick:(UIButton *)sender;- (IBAction)checkBoxClick:(UIButton *)sender;@end@implementation EFSelectGasViewController- (NSArray *)items {        if (!_items) {        _items = @[_firstCheckBox,_secondCheckBox,_thirdCheckBox,_forthCheckBox];    }    return _items;}- (void)viewDidLoad {    [super viewDidLoad];    // Do any additional setup after loading the view from its nib.}- (void)viewWillAppear:(BOOL)animated {        [super viewWillAppear:animated];    [self items];}- (void)didReceiveMemoryWarning {    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}/*#pragma mark - Navigation// In a storyboard-based application, you will often want to do a little preparation before navigation- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {    // Get the new view controller using [segue destinationViewController].    // Pass the selected object to the new view controller.}*/- (IBAction)confromBtnClick:(UIButton *)sender {        [_delegate efSelectGasDelegate:[self.gasNumTextField.text intValue]];    [self.navigationController popViewControllerAnimated:true];}- (IBAction)checkBoxClick:(UIButton *)sender {            for (UIButton * tmp in self.items)    {        tmp.selected = NO;    }    sender.selected = YES;    if (sender.tag == 500) {                self.firstLabel.textColor = [UIColor redColor];        self.secondLabel.textColor = [UIColor blackColor];        self.thirdLabel.textColor = [UIColor blackColor];        self.forthLabel.textColor = [UIColor blackColor];        [_delegate efSelectGasDelegate:20];        [self.navigationController popViewControllerAnimated:true];    } else if (sender.tag == 501) {                self.secondLabel.textColor = [UIColor redColor];        self.firstLabel.textColor = [UIColor blackColor];        self.thirdLabel.textColor = [UIColor blackColor];        self.forthLabel.textColor = [UIColor blackColor];        [_delegate efSelectGasDelegate:50];        [self.navigationController popViewControllerAnimated:true];    } else if (sender.tag == 502) {                self.thirdLabel.textColor = [UIColor redColor];        self.firstLabel.textColor = [UIColor blackColor];        self.secondLabel.textColor = [UIColor blackColor];        self.forthLabel.textColor = [UIColor blackColor];        [self.navigationController popViewControllerAnimated:true];        [_delegate efSelectGasDelegate:100];    } else if (sender.tag == 503) {                self.forthLabel.textColor = [UIColor redColor];        self.firstLabel.textColor = [UIColor blackColor];        self.secondLabel.textColor = [UIColor blackColor];        self.thirdLabel.textColor = [UIColor blackColor];        [_delegate efSelectGasDelegate:150];        [self.navigationController popViewControllerAnimated:true];            }    }@end

0 0
原创粉丝点击