我有一个 UIDatepicker,我在其中添加了边框图像,使其位于 UIDatepicker 边框的顶部。在模拟器中,边框图像正好在 UIDatepicker 边框的顶部,但是当我在 iphone/ipod 设备上运行项目时,边框图像往往不在位置。为什么会这样?
当我点击 settingsButton ..settingsButtonChanged 方法并在 settingsView 中添加日期选择器。
谢谢
更新 :
-(void)viewDidLoad
{
userTimePicker = [[UIDatePicker alloc]init
}
-(IBAction)settingsButtonChanged:(UIButton *)sender
{
UIImageView *settingsImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"settingsViewImage.png"]];
settingsImage.frame = CGRectMake(0.0, 0.0, 280.0, 370.0);
CGFloat height = [UIScreen mainScreen].bounds.size.height;
if(height==568.00)
{
settingsView.frame = CGRectMake(0.0, 50.0, 280.0, 370.0);
}else
{
settingsView.frame = CGRectMake(20.0, 45.0, 280.0, 370.0);
}
settingsView.backgroundColor = [UIColor clearColor];
[settingsView addSubview:settingsImage];
UIImageView *userTimePickerBorder = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"datepickerBorder.png"]];
userTimePickerBorder.frame = CGRectMake(0.0, 0.0, 150.0, 180.0);
userTimePicker.frame = CGRectMake(65.0, 165.0, 150.0, 180.0);
userTimePicker.datePickerMode = UIDatePickerModeTime;
[settingsView addSubview:userTimePicker];
[userTimePicker addSubview:userTimePickerBorder];
[symptomView addSubview:settingsView];
}