Initial commit
This commit is contained in:
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// MyPickerView.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 15/10/19.
|
||||
// Copyright © 2015年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface MyPickerView : UIView
|
||||
@property(nonatomic,copy)UIPickerView*picView;
|
||||
@property(nonatomic,copy)UIButton*cancleButton;
|
||||
@property(nonatomic,copy)UIButton*sureButton;
|
||||
|
||||
@property(nonatomic,strong)NSArray*picArr;
|
||||
@property(nonatomic,copy)NSString*picViewResultString;
|
||||
@property(nonatomic,strong)NSMutableArray*componentArray;
|
||||
@property(nonatomic)NSInteger component;
|
||||
@property(nonatomic)NSString* rowTitle;
|
||||
@property(nonatomic)NSInteger row;
|
||||
@property(nonatomic,strong)UIImageView*backgroundImage;
|
||||
@property(nonatomic)NSInteger heighindex;
|
||||
@property(nonatomic)NSInteger lowindex;
|
||||
@end
|
||||
@@ -0,0 +1,175 @@
|
||||
//
|
||||
// MyPickerView.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 15/10/19.
|
||||
// Copyright © 2015年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MyPickerView.h"
|
||||
#import "AppDelegate.h"
|
||||
#import "BackmassegeModel.h"
|
||||
@interface MyPickerView()<UIPickerViewDataSource,UIPickerViewDelegate>
|
||||
@end
|
||||
@implementation MyPickerView
|
||||
-(instancetype)initWithFrame:(CGRect)frame{
|
||||
|
||||
self=[super initWithFrame:frame];
|
||||
if (self) {
|
||||
|
||||
CGFloat imgWid= kScreenSize.width - 40*2;
|
||||
CGFloat imHeight= kScreenSize.width - 60;
|
||||
|
||||
self.backgroundColor=[UIColor colorWithWhite:0 alpha:0.5];
|
||||
_backgroundImage
|
||||
=[[UIImageView alloc]initWithFrame:CGRectMake(40,kScreenSize.height/2-(kScreenSize.width -30)/2, imgWid, imHeight)];
|
||||
|
||||
_backgroundImage.image=[UIImage imageNamed:@"Box"];
|
||||
[self addSubview:_backgroundImage];
|
||||
_backgroundImage.userInteractionEnabled=YES;
|
||||
UILabel*title=[[UILabel alloc]initWithFrame:CGRectMake(10,10, _backgroundImage.frame.size.width-10*2, 20)];
|
||||
title.text=@"温度设置";
|
||||
title.textAlignment=NSTextAlignmentCenter;
|
||||
[_backgroundImage addSubview:title];
|
||||
|
||||
UILabel*lowLabel=[[UILabel alloc]initWithFrame:CGRectMake(10,title.frame.size.height+20, _backgroundImage.frame.size.width/2, 20)];
|
||||
lowLabel.text=@"最低温度 ";
|
||||
lowLabel.textAlignment=NSTextAlignmentCenter;
|
||||
[_backgroundImage addSubview:lowLabel];
|
||||
|
||||
UILabel*heightLabel=[[UILabel alloc]initWithFrame:CGRectMake(_backgroundImage.frame.size.width/2,title.frame.size.height+20, _backgroundImage.frame.size.width/2, 20)];
|
||||
heightLabel.text=@"最高温度";
|
||||
heightLabel.textAlignment=NSTextAlignmentCenter;
|
||||
[_backgroundImage addSubview:heightLabel];
|
||||
|
||||
_picView=[[UIPickerView alloc]initWithFrame:CGRectMake(10,lowLabel.frame.origin.y + 20,imgWid - 20,imHeight -30 - 40- 20)];
|
||||
_picView.dataSource=self;
|
||||
_picView.delegate=self;
|
||||
[_backgroundImage addSubview:_picView];
|
||||
|
||||
_cancleButton=[UIButton buttonWithType:UIButtonTypeCustom];
|
||||
_cancleButton.backgroundColor=[UIColor lightGrayColor];
|
||||
CGFloat wdspace=40;
|
||||
_cancleButton.frame=CGRectMake(40,_picView.frame.origin.y + _picView.frame.size.height - 10, (_backgroundImage.frame.size.width-3*wdspace)/2, 30);
|
||||
[_cancleButton setTitle:@" 取消" forState:UIControlStateNormal];
|
||||
_cancleButton.layer.masksToBounds=YES;
|
||||
_cancleButton.layer.cornerRadius=4;
|
||||
_cancleButton.userInteractionEnabled=YES;
|
||||
//[_backgroundImage addSubview:_cancleButton];
|
||||
|
||||
_sureButton
|
||||
=[UIButton buttonWithType:UIButtonTypeCustom];
|
||||
_sureButton.frame=CGRectMake(0, _backgroundImage.frame.size.height - 44 + 3, _backgroundImage.frame.size.width, 44);
|
||||
_sureButton.backgroundColor=COLOR_LABEL_TITLE;
|
||||
[_sureButton setTitle:@"确定" forState:UIControlStateNormal];
|
||||
_sureButton.layer.masksToBounds=YES;
|
||||
_sureButton.layer.cornerRadius=4;
|
||||
_sureButton.userInteractionEnabled=YES;
|
||||
[_backgroundImage addSubview:_sureButton];
|
||||
[self dataSource];
|
||||
|
||||
_componentArray=[[NSMutableArray alloc] init];
|
||||
|
||||
UITapGestureRecognizer *sigleTap=[[UITapGestureRecognizer alloc] init ];
|
||||
|
||||
[self addGestureRecognizer:sigleTap];
|
||||
|
||||
CGPoint locationP= [sigleTap locationInView:self];
|
||||
|
||||
BOOL isIn= CGRectContainsPoint( _backgroundImage.frame ,locationP);
|
||||
|
||||
if (!isIn) {
|
||||
|
||||
[sigleTap addTarget:self action:@selector(dissmissView)];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)dissmissView{
|
||||
|
||||
[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"],@[@"~"],@[@"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数据源
|
||||
#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];
|
||||
// NSLog(@"rowtitle%@",rowTitle);
|
||||
|
||||
_rowTitle=rowTitle;
|
||||
return rowTitle;
|
||||
|
||||
}
|
||||
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
|
||||
|
||||
// BackmassegeModel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackInfo"];
|
||||
_component=component;
|
||||
_row=row;
|
||||
_picViewResultString=@"";
|
||||
if (![self.componentArray containsObject:@(component)]) {
|
||||
[self.componentArray addObject:@(component)];
|
||||
}
|
||||
for (int i=0; i<_picArr.count;i++) {
|
||||
if ([self.componentArray containsObject:@(i)]) {
|
||||
NSInteger cIndex = [pickerView selectedRowInComponent:i];
|
||||
|
||||
|
||||
_picViewResultString=[NSString stringWithFormat:@"%@%@",_picViewResultString,_picArr[i][cIndex]];
|
||||
|
||||
}else{
|
||||
|
||||
NSLog(@"%ld",(long)_heighindex);
|
||||
if (i==0) {
|
||||
_picViewResultString=[NSString stringWithFormat:@"%@%@",_picViewResultString ,_picArr[i][_lowindex]];
|
||||
}else if (i==1) {
|
||||
_picViewResultString=[NSString stringWithFormat:@"%@%@",_picViewResultString ,_picArr[i][0]];
|
||||
}else if (i==2){
|
||||
_picViewResultString=[NSString stringWithFormat:@"%@%@",_picViewResultString ,_picArr[i][_heighindex]];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NSLog(@"pick%@",_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 -40)/3;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// MydatePickerView.h
|
||||
// mypick
|
||||
//
|
||||
// Created by imac on 15/11/4.
|
||||
// Copyright © 2015年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
@class MydatePickerView;
|
||||
@protocol MydatePickerViewDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
-(void)doneButtonHaveClick:(MydatePickerView*)pickView resultString:(NSString *)resultString;
|
||||
-(void)cancleButtonClick;
|
||||
-(void)doneButtonClick;
|
||||
|
||||
@end
|
||||
@interface MydatePickerView : UIView<UIPickerViewDelegate,UIPickerViewDataSource>
|
||||
@property(nonatomic,copy)UIPickerView *picView;
|
||||
@property(nonatomic,strong)NSArray *dataArr;
|
||||
@property(nonatomic,copy)UIButton *cancleButton;
|
||||
@property(nonatomic,copy)UIButton *sureButton;
|
||||
@property(nonatomic)NSInteger row;
|
||||
@property(nonatomic)NSInteger compennent;
|
||||
@property(nonatomic,copy)NSString *startString;
|
||||
@property(nonatomic,copy)NSString *endString;
|
||||
@property(nonatomic,copy)NSString *resultString;
|
||||
@property(nonatomic,strong)UIImageView *backgroundImage;
|
||||
|
||||
@property(nonatomic,strong)UILabel *timeLabel;
|
||||
|
||||
@property(nonatomic,strong)UILabel *startLabel;
|
||||
|
||||
@property(nonatomic,strong)UILabel *endLabel;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,158 @@
|
||||
//
|
||||
// MydatePickerView.m
|
||||
// mypick
|
||||
//
|
||||
// Created by imac on 15/11/4.
|
||||
// Copyright © 2015年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MydatePickerView.h"
|
||||
#define kScreenSize [UIScreen mainScreen].bounds.size
|
||||
#include "AppDelegate.h"
|
||||
@implementation MydatePickerView
|
||||
-(instancetype)initWithFrame:(CGRect)frame{
|
||||
self=[super initWithFrame:frame];
|
||||
if (self) {
|
||||
|
||||
CGFloat imgWid= kScreenSize.width - 40*2;
|
||||
CGFloat imHeight= kScreenSize.width - 60;
|
||||
self.backgroundColor=[UIColor colorWithWhite:0 alpha:0.5];
|
||||
_backgroundImage=[[UIImageView alloc]initWithFrame:CGRectMake(40,kScreenSize.height/2-(kScreenSize.width -30)/2, imgWid, imHeight)];
|
||||
|
||||
_backgroundImage.image=[UIImage imageNamed:@"Box"];
|
||||
_backgroundImage.userInteractionEnabled=YES;
|
||||
[self addSubview:_backgroundImage];
|
||||
|
||||
|
||||
UILabel*title=[[UILabel alloc]initWithFrame:CGRectMake(10,10, _backgroundImage.frame.size.width-10*2, 20)];
|
||||
title.text=@"时间设置";
|
||||
title.textAlignment=NSTextAlignmentCenter;
|
||||
[_backgroundImage addSubview:title];
|
||||
|
||||
_startLabel=[[UILabel alloc] initWithFrame:CGRectMake(10,title.frame.size.height+20, _backgroundImage.frame.size.width/2, 20)];
|
||||
_startLabel.text=@"开始时间";
|
||||
_startLabel.font=[UIFont systemFontOfSize:15];
|
||||
_startLabel.textAlignment=NSTextAlignmentCenter;
|
||||
[_backgroundImage addSubview:_startLabel];
|
||||
|
||||
_endLabel=[[UILabel alloc] initWithFrame:CGRectMake(_backgroundImage.frame.size.width/2,title.frame.size.height+20, _backgroundImage.frame.size.width/2, 20)];
|
||||
_endLabel.text=@"结束时间";
|
||||
_endLabel.font=[UIFont systemFontOfSize:15];
|
||||
_endLabel.textAlignment=NSTextAlignmentCenter;
|
||||
[_backgroundImage addSubview:_endLabel];
|
||||
|
||||
|
||||
_picView=[[UIPickerView alloc]initWithFrame:CGRectMake(10,_startLabel.frame.origin.y + 20,imgWid - 20,imHeight -30 - 40- 20)];
|
||||
_picView.dataSource=self;
|
||||
_picView.delegate=self;
|
||||
|
||||
[_backgroundImage addSubview:_picView];
|
||||
|
||||
|
||||
_cancleButton=[UIButton buttonWithType:UIButtonTypeCustom];
|
||||
_cancleButton.backgroundColor=[UIColor lightGrayColor];
|
||||
CGFloat wdspace=40;
|
||||
_cancleButton.frame=CGRectMake(40,_picView.frame.origin.y + _picView.frame.size.height - 10, (_backgroundImage.frame.size.width-3*wdspace)/2, 30);
|
||||
|
||||
|
||||
[_cancleButton setTitle:@" 取消" forState:UIControlStateNormal];
|
||||
_cancleButton.layer.masksToBounds=YES;
|
||||
_cancleButton.layer.cornerRadius=5;
|
||||
_cancleButton.userInteractionEnabled=YES;
|
||||
|
||||
//[_backgroundImage addSubview:_cancleButton];
|
||||
|
||||
_sureButton
|
||||
=[UIButton buttonWithType:UIButtonTypeCustom];
|
||||
_sureButton.frame=CGRectMake(0, _backgroundImage.frame.size.height - 44 + 3, _backgroundImage.frame.size.width, 44);
|
||||
_sureButton.backgroundColor=[UIColor blueColor];
|
||||
|
||||
[_sureButton setTitle:@"确定" forState:UIControlStateNormal];
|
||||
|
||||
// [_sureButton addTarget:self action:@selector(sureButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
_sureButton.backgroundColor=COLOR_LABEL_TITLE;
|
||||
|
||||
_sureButton.layer.masksToBounds=YES;
|
||||
|
||||
_sureButton.layer.cornerRadius=5;
|
||||
|
||||
_sureButton.userInteractionEnabled=YES;
|
||||
|
||||
[_backgroundImage addSubview:_sureButton];
|
||||
|
||||
[self initData];
|
||||
|
||||
UITapGestureRecognizer *sigleTap=[[UITapGestureRecognizer alloc] init ];
|
||||
|
||||
[self addGestureRecognizer:sigleTap];
|
||||
|
||||
CGPoint locationP= [sigleTap locationInView:self];
|
||||
|
||||
BOOL isIn= CGRectContainsPoint( _backgroundImage.frame ,locationP);
|
||||
|
||||
if (!isIn) {
|
||||
|
||||
[sigleTap addTarget:self action:@selector(dissmissView)];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)dissmissView{
|
||||
|
||||
[self removeFromSuperview];
|
||||
|
||||
}
|
||||
-(void)initData{
|
||||
|
||||
_dataArr=@[@[@"0:00",@"0:30",@"1:00",@"1:30",@"2:00",@"2:30",@"3:00",@"3:30",@"4:00",@"4:30",@"5:00",@"5:30",@"6:00",@"6:30",@"7:00",@"7:30",@"8:00",@"8:30",@"9:00",@"9:30",@"10:00",@"10:30",@"11:00",@"11:30",@"12:00",@"12:30",@"13:00",@"13:30",@"14:00",@"14:30",@"15:00",@"15:30",@"16:00",@"16:30",@"17:00",@"17:30",@"18:00",@"18:30",@"19:00",@"19:30",@"20:00",@"20:30",@"21:00",@"21:30",@"22:00",@"22:30",@"23:00",@"23:30"],@[@"0:29",@"0:59",@"1:29",@"1:59",@"2:29",@"2:59",@"3:29",@"3:59",@"4:29",@"4:59",@"5:29",@"5:59",@"6:29",@"6:59",@"7:29",@"7:59",@"8:29",@"8:59",@"9:29",@"9:59",@"10:29",@"10:59",@"11:29",@"11:59",@"12:29",@"12:59",@"13:29",@"13:59",@"14:29",@"14:59",@"15:29",@"15:59",@"16:29",@"16:59",@"17:29",@"17:59",@"18:29",@"18:59",@"19:29",@"19:59",@"20:29",@"20:59",@"21:29",@"21:59",@"22:29",@"22:59",@"23:29",@"23:59",]];
|
||||
|
||||
|
||||
}
|
||||
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
|
||||
NSArray *rowArray=[[NSArray alloc] init];
|
||||
rowArray=_dataArr[component];
|
||||
return rowArray.count;
|
||||
}
|
||||
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
|
||||
return 2;
|
||||
}
|
||||
-(NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
|
||||
|
||||
NSString *rowTitle=nil;
|
||||
rowTitle=_dataArr[component][row];
|
||||
|
||||
return rowTitle;
|
||||
}
|
||||
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
|
||||
_row=row;
|
||||
_compennent=component;
|
||||
if (component==0) {
|
||||
_startString=_dataArr[0][_row];
|
||||
|
||||
}else if(component==1) {
|
||||
|
||||
_endString=_dataArr[1][_row];
|
||||
|
||||
}
|
||||
|
||||
// [_picView selectRow:row inComponent:component animated:YES];
|
||||
|
||||
}
|
||||
|
||||
|
||||
-(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/2;
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// remindCyclePic.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/3/17.
|
||||
// Copyright © 2016年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface remindCyclePic : UIView
|
||||
@property(nonatomic,copy)UIButton*cancleBtn;
|
||||
@property(nonatomic,copy)UIButton*sureBtn
|
||||
;
|
||||
@property(nonatomic,copy)UIPickerView*pic;
|
||||
@property(nonatomic,strong)UIImageView*picBackImg;
|
||||
@property(nonatomic,strong)NSMutableArray*componentArray;
|
||||
@property(nonatomic,strong)NSArray*picArr;
|
||||
|
||||
@property(nonatomic)NSInteger component;
|
||||
@property(nonatomic)NSString* rowTitle;
|
||||
@property(nonatomic)NSInteger row;
|
||||
@property(nonatomic,copy)NSString*picViewResultString;
|
||||
|
||||
@property(nonatomic,copy)NSString*picString;
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,177 @@
|
||||
//
|
||||
// remindCyclePic.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/3/17.
|
||||
// Copyright © 2016年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "remindCyclePic.h"
|
||||
#define CANCLE_BTN 100000100
|
||||
#define SURE_BTN 100000120
|
||||
@interface remindCyclePic()<UIPickerViewDataSource,UIPickerViewDelegate>
|
||||
|
||||
@end
|
||||
@implementation remindCyclePic
|
||||
-(instancetype)initWithFrame:(CGRect)frame{
|
||||
self=[super initWithFrame:frame];
|
||||
if (self) {
|
||||
|
||||
[self initPic];
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)initPic{
|
||||
|
||||
|
||||
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.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];
|
||||
_cancleBtn=[UIButton buttonWithType:UIButtonTypeCustom];
|
||||
_cancleBtn.backgroundColor=[UIColor lightGrayColor];
|
||||
CGFloat wdspace=40;
|
||||
_cancleBtn.frame=CGRectMake(40,_pic.frame.origin.y + _pic.frame.size.height - 10, (_picBackImg.frame.size.width-3*wdspace)/2, 30);
|
||||
[_cancleBtn setTitle:@" 取消" forState:UIControlStateNormal];
|
||||
_cancleBtn.layer.masksToBounds=YES;
|
||||
_cancleBtn.layer.cornerRadius=8;
|
||||
_cancleBtn.userInteractionEnabled=YES;
|
||||
_cancleBtn.tag=CANCLE_BTN;
|
||||
|
||||
//[_picBackImg addSubview:_cancleBtn];
|
||||
|
||||
_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;
|
||||
_sureBtn.tag=SURE_BTN;
|
||||
[_picBackImg addSubview:_sureBtn];
|
||||
[self dataSource];
|
||||
UITapGestureRecognizer *sigleTap=[[UITapGestureRecognizer alloc] init ];
|
||||
|
||||
[self addGestureRecognizer:sigleTap];
|
||||
|
||||
CGPoint locationP= [sigleTap locationInView:self];
|
||||
|
||||
BOOL isIn= CGRectContainsPoint( _picBackImg.frame ,locationP);
|
||||
|
||||
if (!isIn) {
|
||||
|
||||
[sigleTap addTarget:self action:@selector(dissmissView)];
|
||||
|
||||
}
|
||||
|
||||
_componentArray=[[NSMutableArray alloc] init];
|
||||
}
|
||||
|
||||
|
||||
-(void)dissmissView{
|
||||
|
||||
[self removeFromSuperview];
|
||||
|
||||
}
|
||||
|
||||
-(void)dataSource{
|
||||
|
||||
_picArr=@[@[@"1",@"2",@"3",@"4",@"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];
|
||||
|
||||
// if (![self.componentArray containsObject:@(component)]) {
|
||||
// [self.componentArray addObject:@(component)];
|
||||
// }
|
||||
// for (int i=0; i<_picArr.count;i++) {
|
||||
// if ([self.componentArray containsObject:@(i)]) {
|
||||
// NSInteger cIndex = [pickerView selectedRowInComponent:i];
|
||||
//
|
||||
//
|
||||
// _picViewResultString=[NSString stringWithFormat:@"%@%@",_picViewResultString,_picArr[i][cIndex]];
|
||||
//
|
||||
// }else{
|
||||
//
|
||||
// NSLog(@"%ld",(long)_heighindex);
|
||||
// if (i==0) {
|
||||
// _picViewResultString=[NSString stringWithFormat:@"%@%@",_picViewResultString ,_picArr[i][_lowindex]];
|
||||
// }else if (i==1) {
|
||||
// _picViewResultString=[NSString stringWithFormat:@"%@%@",_picViewResultString ,_picArr[i][0]];
|
||||
// }else if (i==2){
|
||||
// _picViewResultString=[NSString stringWithFormat:@"%@%@",_picViewResultString ,_picArr[i][_heighindex]];
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// }
|
||||
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
|
||||
Reference in New Issue
Block a user