このような UIView に UIDatePicker があります (この質問で目立つように、背景色を赤に変更しました)。
UIView を UIDatePicker の周りに合わせて、赤がないようにしたい。これが私のコードです:
-(void) showModalCalendar:(int)tag {
UIViewController* popoverContent = [[UIViewController alloc] init];
UIView *popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 216)];
popoverView.backgroundColor = [UIColor redColor];
// the full UIDatePicker
datePicker=[[UIDatePicker alloc]init];
datePicker.frame=CGRectMake(0,44,320, 216);
// set the locale to en-GB for testing!
NSLocale *uk = [[NSLocale alloc] initWithLocaleIdentifier:@"en_GB"];
[datePicker setLocale:uk];
if(tag == 202) {
datePicker.datePickerMode = UIDatePickerModeDateAndTime;
[datePicker setTag:205];
}
else if(tag == 203) {
datePicker.datePickerMode = UIDatePickerModeTime;
[datePicker setTag:206];
}
[datePicker setMinuteInterval:15];
[datePicker addTarget:self action:@selector(dateDidChange:) forControlEvents:UIControlEventValueChanged];
[popoverView addSubview:datePicker];
popoverContent.view = popoverView;
popoverController = [[UIPopoverController alloc] initWithContentViewController:popoverContent];
popoverController.delegate = (id)self;
[popoverController setPopoverContentSize:CGSizeMake(320, 264) animated:NO];
switch (tag) { // displays the popover datepicker
case 202: // appointment start time
[popoverController presentPopoverFromRect:boApptStart.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
break;
case 203: // appointment end time
[popoverController presentPopoverFromRect:boApptEnd.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
break;
}
}
何をするか、変更する必要がありますか?
更新 - 近づいています!(私は思う):D