128 lines
3.7 KiB
Objective-C
128 lines
3.7 KiB
Objective-C
//
|
|
// XuToWenDuPicview.m
|
|
// Ifish
|
|
//
|
|
// Created by imac on 16/5/6.
|
|
// Copyright © 2016年 imac. All rights reserved.
|
|
//
|
|
|
|
#import "XuToWenDuPicview.h"
|
|
|
|
@interface XuToWenDuPicview()<UIPickerViewDataSource,UIPickerViewDelegate>
|
|
|
|
@end
|
|
@implementation XuToWenDuPicview
|
|
|
|
-(instancetype)initWithFrame:(CGRect)frame{
|
|
self=[super initWithFrame:frame];
|
|
if (self) {
|
|
|
|
[self initPicview];
|
|
|
|
}
|
|
return self;
|
|
}
|
|
-(void)initPicview{
|
|
|
|
|
|
CGFloat imgWid= kScreenSize.width - 40*2;
|
|
CGFloat imHeight= kScreenSize.width - 60;
|
|
self.backgroundColor=[UIColor colorWithWhite:0 alpha:0.5];
|
|
_picBackImg
|
|
=[[UIImageView alloc]initWithFrame:CGRectMake(40,kScreenSize.height/2-(kScreenSize.width -30)/2, imgWid, imHeight)];
|
|
_picBackImg.image=[UIImage imageNamed:@"Box"];
|
|
[self addSubview:_picBackImg];
|
|
_picBackImg.userInteractionEnabled=YES;
|
|
UILabel*title=[[UILabel alloc]initWithFrame:CGRectMake(10, 10, _picBackImg.frame.size.width-10*2, 20)];
|
|
title.text=@"设置加热温度";
|
|
title.font=[UIFont systemFontOfSize:24];
|
|
title.textAlignment=NSTextAlignmentCenter;
|
|
[_picBackImg addSubview:title];
|
|
|
|
_pic=[[UIPickerView alloc]initWithFrame:CGRectMake(10,title.frame.origin.y + 20,imgWid - 20,imHeight -30 - 40- 20)];
|
|
_pic.dataSource=self;
|
|
_pic.delegate=self;
|
|
[_picBackImg addSubview:_pic];
|
|
|
|
_sureBtn
|
|
=[UIButton buttonWithType:UIButtonTypeCustom];
|
|
_sureBtn.frame=CGRectMake(0, _picBackImg.frame.size.height - 44 + 3, _picBackImg.frame.size.width, 44);
|
|
|
|
_sureBtn.backgroundColor=COLOR_LABEL_TITLE;
|
|
[_sureBtn setTitle:@"确定" forState:UIControlStateNormal];
|
|
_sureBtn.layer.masksToBounds=YES;
|
|
_sureBtn.layer.cornerRadius=8;
|
|
_sureBtn.userInteractionEnabled=YES;
|
|
[_picBackImg addSubview:_sureBtn];
|
|
|
|
[self dataSource];
|
|
|
|
_componentArray=[[NSMutableArray alloc] init];
|
|
UITapGestureRecognizer*tapgestureRecognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(XuToPicDismissAction:)];
|
|
[self addGestureRecognizer:tapgestureRecognizer];
|
|
|
|
|
|
}
|
|
-(void)XuToPicDismissAction:(UITapGestureRecognizer *)tapgestrue{
|
|
|
|
[self removeFromSuperview];
|
|
|
|
}
|
|
|
|
-(void)dataSource{
|
|
_picArr=@[@[@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23",@"24",@"25",@"26",@"27",@"28",@"29",@"30",@"31",@"32",@"33",@"34",@"35",@"36",@"37",@"38",@"39",@"40",@"41",@"42",@"43",@"44",@"45",@"46",@"47",@"48",@"49",@"50"]];
|
|
|
|
}
|
|
|
|
#pragma mark picView数据源
|
|
|
|
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
|
|
NSInteger component;
|
|
component=_picArr.count;
|
|
return component;
|
|
}
|
|
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
|
|
|
|
NSArray *rowArray=[[NSArray alloc] init];
|
|
rowArray=_picArr[component];
|
|
return rowArray.count;
|
|
|
|
}
|
|
|
|
#pragma mark picView代理
|
|
-(NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
|
|
|
|
NSString *rowTitle=nil;
|
|
|
|
rowTitle=_picArr[component][row];
|
|
|
|
|
|
_rowTitle=rowTitle;
|
|
return rowTitle;
|
|
|
|
}
|
|
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
|
|
|
|
NSLog(@"**********4");
|
|
_component=component;
|
|
_row=row;
|
|
_picViewResultString=_picArr[0][row];
|
|
|
|
NSLog(@"_picViewResultString%@",_picViewResultString);
|
|
|
|
|
|
|
|
}
|
|
|
|
-(CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component{
|
|
|
|
return pickerView.frame.size.height/5;;
|
|
}
|
|
|
|
-(CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component{
|
|
return pickerView.frame.size.width;
|
|
}
|
|
|
|
|
|
@end
|