UIDate Picker background color [duplicate]
HI I would like to change the background color of the UIDatePicker from the current glossy image to clear just like in this example
Any ideas how to do that? I tried
datepicker.backgroundColor = [UIColor clearColor];
but it didnt work.
UIDatePicker contains one subview. That subview, in turn, contains 15 other subviews that form UIDatePicker's appearance. The first and the last of them are the background, so to make it transparent just turn them off and set background color of main subview to clearColor:
// create the picker
UIDatePicker *datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 40, 320, 320)];
// add it to some view first
[actionSheet addSubview:datePicker];
[datePicker release];
// clear the background of the main subview
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];
精彩评论