gpt4 book ai didi

ios - UIDatePicker 自定义

转载 作者:可可西里 更新时间:2023-11-01 04:53:25 25 4
gpt4 key购买 nike

我已将 UIDatePicker 自定义到一个级别,并将其添加到 UIAlertView。

enter image description here

但是我在日期选择器的底部和顶部出现了黑色,如何去除它。我希望日期选择器整洁干净。

我用来实现这个的代码:

UIDatePicker *datePicker = [[UIDatePicker alloc] init];
datePicker.frame=CGRectMake(20, 45.0, 240.0, 150.0);
datePicker.minimumDate=[NSDate date];

//Forget about this logic.

NSString *alertTitleString=@"";
if(self.presentingViewController !=nil)
{
alertTitleString=@"Select Date and Time";
[datePicker setDatePickerMode:UIDatePickerModeDateAndTime];
}
else
{
alertTitleString=@"Select Time";
[datePicker setDatePickerMode:UIDatePickerModeTime];

}
[datePicker setDate:[NSDate date]];

UIView *view = [[datePicker subviews] objectAtIndex:0];
[view setBackgroundColor:[UIColor clearColor]]; // hide the first and the last subviews
[[[view subviews] objectAtIndex:0] setHidden:YES];
[[[view subviews] lastObject] setHidden:YES];



UIAlertView *eventStartDateAlert = [[UIAlertView alloc] initWithTitle:alertTitleString message:@"\n\n\n\n\n\n\n\n" delegate:self cancelButtonTitle:NSLocalizedString(@"OK", @"Ok") otherButtonTitles:nil];
eventStartDateAlert.delegate = self;
[eventStartDateAlert addSubview:datePicker];
[eventStartDateAlert show];

最佳答案

基本上您想要做的是移除顶部和底部的渐变,对吧?

这将起作用,至少对于 iOS 5 和 6。

[view.subviews[5]  setHidden:YES];
[view.subviews[11] setHidden:YES];
[view.subviews[17] setHidden:YES];

关于ios - UIDatePicker 自定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16273572/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com