-(void)GreateDatePicker33
{
if ([self.Type isEqualToString:@"car"])
{ //[self.toolBar setHidden:YES];
//self.navigationController.hidesBottomBarWhenPushed=YES;
DatePickerToolbar = [[UIView alloc] initWithFrame:CGRectMake(0.0, 220.0, 320.0, 45.0)];
DatePickerToolbar.autoresizingMask = 0;
//DatePickerToolbar.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bgtitle.png"]];
[DatePickerToolbar setBackgroundColor: [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:0.5]];
leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
[leftButton setBackgroundImage:[UIImage imageNamed:@"bgbtn.png"] forState:UIControlStateNormal];
[leftButton setTitle:@"取消" forState:UIControlStateNormal];
[leftButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
leftButton.titleLabel.font = [UIFont boldSystemFontOfSize:12];
leftButton.frame = CGRectMake(10.0, 8.0, 40, 30);
[leftButton addTarget:self action:@selector(RemoveDatePicker) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
[rightButton setBackgroundImage:[UIImage imageNamed:@"bgbtn.png"] forState:UIControlStateNormal];
[rightButton setTitle:@"完成" forState:UIControlStateNormal];
[rightButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
rightButton.titleLabel.font = [UIFont boldSystemFontOfSize:12];
rightButton.frame = CGRectMake(270, 8.0, 40.0, 30.0);
[rightButton addTarget:self action:@selector(GetCarLocation) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
UISegmentedControl *segmented = [[UISegmentedControl alloc] initWithFrame:CGRectMake(105.0, 8.0, 110.0, 30.0)];
segmented.segmentedControlStyle=UISegmentedControlStyleBar;
[segmented insertSegmentWithTitle:@"今天" atIndex:0 animated:NO];
[segmented insertSegmentWithTitle:@"昨天" atIndex:1 animated:NO];
segmented.selectedSegmentIndex = 0;
segmented.tintColor = [UIColor colorWithRed:31.0/255.0 green:157.0/255.0 blue:202.0/255.0 alpha:0.5];
[segmented addTarget:self action:@selector(DatePickerSegmentChanged:) forControlEvents:UIControlEventValueChanged];
[DatePickerToolbar addSubview:segmented];
[DatePickerToolbar addSubview:leftButton];
[DatePickerToolbar addSubview:rightButton];
[[inCarTimeAppDelegate sharedAppDelegate].mainTabController.view addSubview:DatePickerToolbar];
datePicker = [[UIPickerView alloc] init];
CGRect rect = datePicker.frame;
rect.origin.y = 480 - rect.size.height;
datePicker.frame = rect;
datePicker.showsSelectionIndicator = YES;
[datePicker setBackgroundColor:[UIColor clearColor]];
datePicker.autoresizingMask = UIViewAutoresizingFlexibleWidth;
datePicker.delegate=self; //设置委托
[[inCarTimeAppDelegate sharedAppDelegate].mainTabController.view addSubview:datePicker];
[self showToday];
[segmented release];
[leftItem release];
[rightItem release];
}
}
-(void)GreateDatePicker
{
if ([self.Type isEqualToString:@"car"])
{ //[self.toolBar setHidden:YES];
/*UIBarButtonItem *bar1 =[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self action:@selector(cancelPressed:)] autorelease];
UIBarButtonItem *bar2 =[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil] autorelease];
UIBarButtonItem *bar3 =[[[UIBarButtonItem alloc]initWithTitle:@"Save" style:UIBarButtonSystemItemCancel target:self action:@selector(saveButtonClick:)] autorelease];
bar3.style = UIBarButtonItemStyleBordered;*/
UIBarButtonItem *spaceItem =[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil] autorelease];
UIBarButtonItem *leftItem = [[[UIBarButtonItem alloc]initWithTitle:@"取消" style:UIBarButtonSystemItemCancel target:self action:@selector(RemoveDatePicker)] autorelease];
UIBarButtonItem *rightItem = [[[UIBarButtonItem alloc]initWithTitle:@"完成" style:UIBarButtonSystemItemCancel target:self action:@selector(GetCarLocation)] autorelease];
UISegmentedControl *segmented = [[[UISegmentedControl alloc] initWithFrame:CGRectMake(105.0, 8.0, 110.0, 30.0)] autorelease];
segmented.segmentedControlStyle=UISegmentedControlStyleBar;
[segmented insertSegmentWithTitle:@"今天" atIndex:0 animated:NO];
[segmented insertSegmentWithTitle:@"昨天" atIndex:1 animated:NO];
segmented.selectedSegmentIndex = 0;
segmented.tintColor = [UIColor grayColor];
[segmented addTarget:self action:@selector(DatePickerSegmentChanged:) forControlEvents:UIControlEventValueChanged];
UIBarButtonItem *centerItem = [[[UIBarButtonItem alloc] initWithCustomView:segmented] autorelease];
DateToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0, 220.0, 320.0, 45.0)];
DateToolbar.alpha = 1.000;
DateToolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
DateToolbar.barStyle = UIBarStyleBlackTranslucent;
DateToolbar.clearsContextBeforeDrawing = YES;
DateToolbar.clipsToBounds = NO;
DateToolbar.contentMode = UIViewContentModeScaleToFill;
DateToolbar.hidden = NO;
DateToolbar.multipleTouchEnabled = NO;
DateToolbar.opaque = NO;
DateToolbar.tag = 0;
DateToolbar.userInteractionEnabled = YES;
[DateToolbar setItems:[NSArray arrayWithObjects:leftItem,spaceItem,centerItem,spaceItem,rightItem,nil] animated:NO];
[[inCarTimeAppDelegate sharedAppDelegate].mainTabController.view addSubview:DateToolbar];
datePicker = [[[UIPickerView alloc] init] autorelease];
CGRect rect = datePicker.frame;
rect.origin.y = 480 - rect.size.height;
datePicker.frame = rect;
datePicker.showsSelectionIndicator = YES;
[datePicker setBackgroundColor:[UIColor clearColor]];
datePicker.autoresizingMask = UIViewAutoresizingFlexibleWidth;
datePicker.delegate=self; //设置委托
[[inCarTimeAppDelegate sharedAppDelegate].mainTabController.view addSubview:datePicker];
[self showToday];
//[segmented release];
//[leftItem release];
//[rightItem release];
}
}